diff --git a/k8s/apps/iperf3/daemonset.yaml b/k8s/apps/iperf3/daemonset.yaml index 61ccd44..d911896 100644 --- a/k8s/apps/iperf3/daemonset.yaml +++ b/k8s/apps/iperf3/daemonset.yaml @@ -11,23 +11,61 @@ spec: labels: app: iperf3-server spec: + serviceAccountName: iperf3-server subdomain: iperf3 initContainers: - - name: set-hostname - image: busybox:1.35 - command: ['sh', '-c'] - args: - - | - NODE_NAME=$(echo $NODE_NAME | cut -d'.' -f1 | tr '[:upper:]' '[:lower:]') - echo "iperf3-${NODE_NAME}" > /etc/hostname - hostname "iperf3-${NODE_NAME}" - securityContext: - privileged: true + - name: create-service + image: bitnami/kubectl:latest env: - name: NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + command: + - /bin/bash + - -c + - | + # Clean node name for service name + NODE_CLEAN=$(echo "$NODE_NAME" | cut -d'.' -f1 | tr '[:upper:]' '[:lower:]' | tr '_' '-') + SERVICE_NAME="iperf3-${NODE_CLEAN}" + + # Create service for this pod + kubectl apply -f - <