From 70ac18f720b646d9d2ca588442dc78367eafb28e Mon Sep 17 00:00:00 2001 From: Gitesh Koli Date: Fri, 28 Feb 2020 16:46:09 -0500 Subject: [PATCH] Corrected CronJob volume Path and the expected results --- .../builtinpluginconsts/varreference.go | 2 +- api/krusty/variableref_test.go | 197 +++++++++++++++++- 2 files changed, 196 insertions(+), 3 deletions(-) diff --git a/api/konfig/builtinpluginconsts/varreference.go b/api/konfig/builtinpluginconsts/varreference.go index cee1e013a..f2a418d45 100644 --- a/api/konfig/builtinpluginconsts/varreference.go +++ b/api/konfig/builtinpluginconsts/varreference.go @@ -30,7 +30,7 @@ varReference: - path: spec/jobTemplate/spec/template/spec/initContainers/volumeMounts/mountPath kind: CronJob -- path: spec/jobTemplate/spec/template/spec/volumes/nfs/server +- path: spec/jobTemplate/spec/template/volumes/nfs/server kind: CronJob - path: spec/template/spec/containers/args diff --git a/api/krusty/variableref_test.go b/api/krusty/variableref_test.go index a7754c88c..13173c75f 100644 --- a/api/krusty/variableref_test.go +++ b/api/krusty/variableref_test.go @@ -1621,8 +1621,7 @@ spec: - metadata: name: www spec: - accessModes: [ "ReadWriteOnce" ] - storageClassName: "my-storage-class" + accessModes: [ "ReadWriteMany" ] nfs: server: $(NFS_SERVER_SERVICE_NAME).default.srv.cluster.local path: / @@ -1762,6 +1761,200 @@ spec: readOnly: false server: kustomized-nfs-server-service.default.srv.cluster.local --- +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: kustomized-hello +spec: + jobTemplate: + spec: + template: + spec: + containers: + - args: + - /bin/sh + - -c + - date; echo Hello from the Kubernetes cluster + image: busybox + name: hello + restartPolicy: OnFailure + volumeMounts: + - mountPath: /app/shared-files + name: nfs-files-vol + volumes: + - name: nfs-files-vol + nfs: + path: / + readOnly: false + server: kustomized-nfs-server-service.default.srv.cluster.local + schedule: '*/1 * * * *' +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + labels: + k8s-app: fluentd-logging + name: kustomized-fluentd-elasticsearch + namespace: kube-system +spec: + selector: + matchLabels: + name: fluentd-elasticsearch + template: + metadata: + labels: + name: fluentd-elasticsearch + spec: + containers: + - image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2 + name: fluentd-elasticsearch + resources: + limits: + memory: 200Mi + requests: + cpu: 100m + memory: 200Mi + volumeMounts: + - mountPath: /var/log + name: varlog + - mountPath: /var/lib/docker/containers + name: varlibdockercontainers + readOnly: true + - mountPath: /app/shared-files + name: nfs-files-vol + terminationGracePeriodSeconds: 30 + tolerations: + - effect: NoSchedule + key: node-role.kubernetes.io/master + volumes: + - hostPath: + path: /var/log + name: varlog + - hostPath: + path: /var/lib/docker/containers + name: varlibdockercontainers + - name: nfs-files-vol + nfs: + path: / + readOnly: false + server: kustomized-nfs-server-service.default.srv.cluster.local +--- +apiVersion: apps/v1 +kind: ReplicaSet +metadata: + labels: + app: guestbook + tier: frontend + name: kustomized-frontend +spec: + replicas: 3 + selector: + matchLabels: + tier: frontend + template: + metadata: + labels: + tier: frontend + spec: + containers: + - image: gcr.io/google_samples/gb-frontend:v3 + name: php-redis + volumeMounts: + - mountPath: /app/shared-files + name: nfs-files-vol + volumes: + - name: nfs-files-vol + nfs: + path: / + readOnly: false + server: kustomized-nfs-server-service.default.srv.cluster.local +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: kustomized-web +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + serviceName: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - image: k8s.gcr.io/nginx-slim:0.8 + name: nginx + ports: + - containerPort: 80 + name: web + volumeMounts: + - mountPath: /usr/share/nginx/html + name: www + terminationGracePeriodSeconds: 10 + volumeClaimTemplates: + - metadata: + name: www + spec: + accessModes: + - ReadWriteMany + nfs: + path: / + readOnly: false + server: kustomized-nfs-server-service.default.srv.cluster.local +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + app: myapp + name: kustomized-myapp-pod +spec: + containers: + - image: nginx:1.15.7-alpine + name: nginx + ports: + - containerPort: 80 + name: http + volumeMounts: + - mountPath: /app/shared-files + name: nfs-files-vol + volumes: + - name: nfs-files-vol + nfs: + path: / + readOnly: false + server: kustomized-nfs-server-service.default.srv.cluster.local +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: kustomized-pi +spec: + backoffLimit: 4 + template: + spec: + containers: + - command: + - perl + - -Mbignum=bpi + - -wle + - print bpi(2000) + image: perl + name: pi + volumeMounts: + - mountPath: /app/shared-files + name: nfs-files-vol + restartPolicy: Never + volumes: + - name: nfs-files-vol + nfs: + path: / + readOnly: false + server: kustomized-nfs-server-service.default.srv.cluster.local +--- apiVersion: v1 kind: PersistentVolume metadata: