add: dockerfile and deploy command
This commit is contained in:
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
# Build Stage
|
||||
FROM rust:latest AS builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN cargo build --release
|
||||
|
||||
# Runtime Stage
|
||||
FROM debian:stable-slim
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/target/release/handler .
|
||||
CMD ["./handler"]
|
||||
16
Makefile
Normal file
16
Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 0
|
||||
PATH_VERSION = 1
|
||||
|
||||
TAG = $(MAJOR_VERSION).$(MINOR_VERSION).$(PATH_VERSION)
|
||||
|
||||
build:
|
||||
docker build . -t skubelb-handler:$(TAG)
|
||||
docker tag skubelb-handler:$(TAG) us-west4-docker.pkg.dev/nixernetes/images/skubelb-handler:$(TAG)
|
||||
|
||||
kube:
|
||||
cat kubernetes.yaml.tmpl | sed 's/TAG/$(TAG)/' > kubernetes.yaml
|
||||
|
||||
deploy: build kube
|
||||
docker push us-west4-docker.pkg.dev/nixernetes/images/skubelb-handler:$(TAG)
|
||||
kubectl apply -f kubernetes.yaml
|
||||
41
kubernetes.yaml
Normal file
41
kubernetes.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: skubelb
|
||||
namespace: skubelb
|
||||
labels:
|
||||
k8s-app: skubelb
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
name: skubelb
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: skubelb
|
||||
spec:
|
||||
tolerations:
|
||||
# these tolerations are to have the daemonset runnable on control plane nodes
|
||||
# remove them if your control plane nodes should not run pods
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
containers:
|
||||
- name: skubelb
|
||||
image: us-west4-docker.pkg.dev/nixernetes/images/skubelb-handler:0.0.1
|
||||
env:
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.hostIP
|
||||
command: ["sh", "-c", "./handler -s 10.128.0.2:8888 -l ${NODE_IP}"]
|
||||
resources:
|
||||
limits:
|
||||
memory: 200Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 100Mi
|
||||
terminationGracePeriodSeconds: 30
|
||||
41
kubernetes.yaml.tmpl
Normal file
41
kubernetes.yaml.tmpl
Normal file
@@ -0,0 +1,41 @@
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: skubelb
|
||||
namespace: skubelb
|
||||
labels:
|
||||
k8s-app: skubelb
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
name: skubelb
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: skubelb
|
||||
spec:
|
||||
tolerations:
|
||||
# these tolerations are to have the daemonset runnable on control plane nodes
|
||||
# remove them if your control plane nodes should not run pods
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
- key: node-role.kubernetes.io/master
|
||||
operator: Exists
|
||||
effect: NoSchedule
|
||||
containers:
|
||||
- name: skubelb
|
||||
image: us-west4-docker.pkg.dev/nixernetes/images/skubelb-handler:TAG
|
||||
env:
|
||||
- name: NODE_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.hostIP
|
||||
command: ["sh", "-c", "./handler -s 10.128.0.2:8888 -l ${NODE_IP}"]
|
||||
resources:
|
||||
limits:
|
||||
memory: 200Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 100Mi
|
||||
terminationGracePeriodSeconds: 30
|
||||
@@ -3,7 +3,7 @@ use std::time::Duration;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use log::error;
|
||||
use log::{error, info};
|
||||
|
||||
use anyhow::Result;
|
||||
use env_logger::Env;
|
||||
@@ -37,6 +37,7 @@ fn handle(remote: &str, listen: &str) -> Result<()> {
|
||||
let url = format!("http://{}/register/{}", remote, listen);
|
||||
loop {
|
||||
sleep(Duration::from_secs(20));
|
||||
info!("sending post to {}", url);
|
||||
client.post(&url).send()?;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user