From 523de62a1ec094d683876622a3f69f1dbeea5f32 Mon Sep 17 00:00:00 2001 From: Raju Dawadi Date: Sun, 3 Dec 2023 17:42:36 -0500 Subject: [PATCH] refactor k8s manifest files and add dns policy for daemonset --- k8s/README.md | 23 +++++++++++++++-------- k8s/clusterrole.yaml | 2 +- k8s/goreplay.yaml | 22 +++++++++++++++------- k8s/nginx.yaml | 3 +-- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/k8s/README.md b/k8s/README.md index aa018aab..c44d4ae1 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -77,15 +77,23 @@ Following format supported: apiVersion: apps/v1 kind: DaemonSet metadata: -  name: goreplay-daemon + name: goreplay-daemon spec: -  template: -    spec: + selector: + matchLabels: + name: goreplay-daemon + template: + metadata: + labels: + name: goreplay-daemon + spec: hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet serviceAccountName: goreplay -      containers: -      - name: goreplay -        image: buger/goreplay:2.0.0-rc2 + containers: + - name: goreplay + imagePullPolicy: Always + image: buger/goreplay:2.0.0-rc2 command: - "--input-raw k8s://deployments/nginx:80" - "--output-stdout" @@ -122,7 +130,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: ngnix-service + name: nginx-service spec: selector: app: nginx @@ -141,4 +149,3 @@ Find url for your service using `kubectl get svc` or `minikube service --url ngn Get GoReplay logs, and check if it capture traffic of your service. `kubectl logs -n goreplay -l name=goreplay-daemon --all-containers` - diff --git a/k8s/clusterrole.yaml b/k8s/clusterrole.yaml index e43b0271..fca91145 100644 --- a/k8s/clusterrole.yaml +++ b/k8s/clusterrole.yaml @@ -11,4 +11,4 @@ rules: verbs: ["get", "watch", "list"] - apiGroups: ["apps"] resources: ["daemonsets"] - verbs: ["get", "watch", "list"] \ No newline at end of file + verbs: ["get", "watch", "list"] diff --git a/k8s/goreplay.yaml b/k8s/goreplay.yaml index 34c57eb3..d879cf64 100644 --- a/k8s/goreplay.yaml +++ b/k8s/goreplay.yaml @@ -1,15 +1,23 @@ apiVersion: apps/v1 kind: DaemonSet metadata: -  name: goreplay-daemon + name: goreplay-daemon spec: -  template: -    spec: + selector: + matchLabels: + name: goreplay-daemon + template: + metadata: + labels: + name: goreplay-daemon + spec: hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet # For replaying to local dns eg. --output-http http://nginx-service.goreplay.svc.cluster.local:80 serviceAccountName: goreplay -      containers: -      - name: goreplay -        image: buger/goreplay:2.0.0-rc2 + containers: + - name: goreplay + imagePullPolicy: Always + image: buger/goreplay:2.0.0-rc2 command: - "--input-raw k8s://deployments/nginx:80" - - "--output-stdout" \ No newline at end of file + - "--output-stdout" diff --git a/k8s/nginx.yaml b/k8s/nginx.yaml index 89853963..8fc2756d 100644 --- a/k8s/nginx.yaml +++ b/k8s/nginx.yaml @@ -24,7 +24,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: ngnix-service + name: nginx-service spec: selector: app: nginx @@ -33,4 +33,3 @@ spec: - protocol: TCP port: 80 targetPort: 80 - \ No newline at end of file