fix(tasks/iperf2): headless svc, pod-ready

This commit is contained in:
JJGadgets
2023-12-22 00:52:59 +08:00
parent 7c3d73d8fb
commit e62fb5875e
3 changed files with 38 additions and 14 deletions

View File

@@ -25,17 +25,35 @@ tasks:
NAME: &name-fail '{{ or .NAME (fail "Missing `NAME` environment variable!") }}'
NS: *ns-fail
cmds:
- until [[ $(kubectl -n "{{.NS}}" get pod "{{.NAME}}" -o jsonpath='{.items[*].status.phase}') == "Pending" ]]; do sleep 1; done
- until [[ $(kubectl -n {{.NS}} get pod {{.NAME}} -o jsonpath='{.items[*].status.phase}') == "Pending" ]]; do sleep 1; done
wait-pod-running:
aliases: [waitr]
internal: true
desc: Wait for a job's pod to change its status to pending
desc: Wait for a job's pod to change its status to running
vars:
NAME: *name-fail
NS: *ns-fail
cmds:
- until [[ $(kubectl -n "{{.NS}}" get pod "{{.NAME}}" -o jsonpath='{.items[*].status.phase}') == "Running" ]]; do sleep 1; done
- until [[ $(kubectl -n {{.NS}} get pod {{.NAME}} -o jsonpath='{.items[*].status.phase}') == "Running" ]]; do sleep 1; done
wait-pod-running-v2:
internal: true
desc: Wait for a job's pod to change its status to running
vars:
NAME: *name-fail
NS: *ns-fail
cmds:
- until kubectl wait pod -n {{.NS}} {{.NAME}} --for-jsonpath='{.items[*].status.phase}'=Running --timeout=-; do sleep 1; done
wait-pod-ready:
internal: true
desc: Wait for a pod to be ready
vars:
NAME: *name-fail
NS: *ns-fail
cmds:
- until kubectl wait pod -n {{.NS}} {{.NAME}} --for=condition=Ready --timeout=1h; do sleep 1; done
wait-pod-delete:
aliases: [waitd]
@@ -147,7 +165,7 @@ tasks:
cmds:
- cat ./server.yaml | envsubst | kubectl apply -f -
- defer: cat ./server.yaml | envsubst | kubectl delete -f -
- task: wait-pod-running
- task: wait-pod-ready
vars:
NAME: '-l job-name={{.SERVER_NAME}}'
NS: '{{.SERVER_NS}}'
@@ -241,4 +259,4 @@ tasks:
- |- # resume Flux Kustomization
[[ {{.KS}} != "disabled" ]] && flux resume kustomization -n {{.KSNS}} {{.KS}} || true
- |- # remove reason annotation from Flux Kustomization
[[ {{.KS}} != "disabled" ]] && kubectl annotate kustomizations.kustomize.toolkit.fluxcd.io -n {{.KSNS}} {{.KS}} scaledown.home.arpa/reason- || true
[[ {{.KS}} != "disabled" ]] && kubectl annotate kustomizations.kustomize.toolkit.fluxcd.io -n {{.KSNS}} {{.KS}} scaledown.home.arpa/reason- || true

View File

@@ -12,7 +12,10 @@ spec:
spec:
automountServiceAccountToken: false
restartPolicy: Never
nodeName: ${CLIENT_NODE}
# hostNetwork: true
dnsPolicy: "ClusterFirstWithHostNet"
nodeSelector:
kubernetes.io/hostname: "${CLIENT_NODE}"
containers:
- name: *name
image: public.ecr.aws/debian/debian:bookworm-20230411-slim
@@ -46,4 +49,4 @@ spec:
matchLabels:
job-name: "${SERVER_NAME}"
ports:
- port: 5001
- port: 5001

View File

@@ -12,7 +12,9 @@ spec:
spec:
automountServiceAccountToken: false
restartPolicy: "Never"
nodeName: "${SERVER_NODE}"
nodeSelector:
kubernetes.io/hostname: "${SERVER_NODE}"
# hostNetwork: true
containers:
- name: *name
image: "public.ecr.aws/debian/debian:bookworm-20230411-slim"
@@ -50,13 +52,14 @@ metadata:
jobs.home.arpa/iperf2: "server"
spec:
type: ClusterIP
clusterIP: "None"
selector:
job-name: *name
ports:
- name: "iperf"
protocol: "TCP"
port: &port ${SERVER_PORT}
targetPort: *port
# ports:
# - name: "iperf"
# protocol: "TCP"
# port: &port ${SERVER_PORT}
# targetPort: *port
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
@@ -83,4 +86,4 @@ spec:
egress:
- to:
- ipBlock:
cidr: "0.0.0.0/0"
cidr: "0.0.0.0/0"