From 617d608be4a7f6311285f03f4beb417fc6e54d66 Mon Sep 17 00:00:00 2001 From: Lachlan Evenson Date: Mon, 29 Jan 2024 20:53:29 -0800 Subject: [PATCH] Chapter 11 & 12 updates Signed-off-by: Lachlan Evenson --- 11-1-fluentd.yaml | 38 ++++++++++++++++++++++++++++++++++ 11-1-simple-config.txt | 3 --- 11-2-kuard-config.yaml | 31 --------------------------- 11-2-nginx-fast-storage.yaml | 23 ++++++++++++++++++++ 11-3-kuard-secret.yaml | 17 --------------- 11-4-kuard-secret-ips.yaml | 19 ----------------- 12-1-job-oneshot.yaml | 18 ++++++++++++++++ 12-2-job-oneshot-failure1.yaml | 24 +++++++++++++++++++++ 12-3-job-parallel.yaml | 25 ++++++++++++++++++++++ 12-4-rs-queue.yaml | 26 +++++++++++++++++++++++ 12-5-service-queue.yaml | 16 ++++++++++++++ 12-6-load-queue.sh | 9 ++++++++ 12-7-job-consumers.yaml | 29 ++++++++++++++++++++++++++ 13 files changed, 208 insertions(+), 70 deletions(-) create mode 100644 11-1-fluentd.yaml delete mode 100644 11-1-simple-config.txt delete mode 100644 11-2-kuard-config.yaml create mode 100644 11-2-nginx-fast-storage.yaml delete mode 100644 11-3-kuard-secret.yaml delete mode 100644 11-4-kuard-secret-ips.yaml create mode 100644 12-1-job-oneshot.yaml create mode 100644 12-2-job-oneshot-failure1.yaml create mode 100644 12-3-job-parallel.yaml create mode 100644 12-4-rs-queue.yaml create mode 100644 12-5-service-queue.yaml create mode 100755 12-6-load-queue.sh create mode 100644 12-7-job-consumers.yaml diff --git a/11-1-fluentd.yaml b/11-1-fluentd.yaml new file mode 100644 index 0000000..ca46c0a --- /dev/null +++ b/11-1-fluentd.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: fluentd + labels: + app: fluentd +spec: + selector: + matchLabels: + app: fluentd + template: + metadata: + labels: + app: fluentd + spec: + containers: + - name: fluentd + image: fluent/fluentd:v0.14.10 + resources: + limits: + memory: 200Mi + requests: + cpu: 100m + memory: 200Mi + volumeMounts: + - name: varlog + mountPath: /var/log + - name: varlibdockercontainers + mountPath: /var/lib/docker/containers + readOnly: true + terminationGracePeriodSeconds: 30 + volumes: + - name: varlog + hostPath: + path: /var/log + - name: varlibdockercontainers + hostPath: + path: /var/lib/docker/containers diff --git a/11-1-simple-config.txt b/11-1-simple-config.txt deleted file mode 100644 index 5398066..0000000 --- a/11-1-simple-config.txt +++ /dev/null @@ -1,3 +0,0 @@ -# This is a sample config file that I might use to configure an application -parameter1 = value1 -parameter2 = value2 diff --git a/11-2-kuard-config.yaml b/11-2-kuard-config.yaml deleted file mode 100644 index efeb6be..0000000 --- a/11-2-kuard-config.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: kuard-config -spec: - containers: - - name: test-container - image: gcr.io/kuar-demo/kuard-amd64:1 - imagePullPolicy: Always - command: - - "/kuard" - - "$(EXTRA_PARAM)" - env: - - name: ANOTHER_PARAM - valueFrom: - configMapKeyRef: - name: my-config - key: another-param - - name: EXTRA_PARAM - valueFrom: - configMapKeyRef: - name: my-config - key: extra-param - volumeMounts: - - name: config-volume - mountPath: /config - volumes: - - name: config-volume - configMap: - name: my-config - restartPolicy: Never diff --git a/11-2-nginx-fast-storage.yaml b/11-2-nginx-fast-storage.yaml new file mode 100644 index 0000000..90ab57a --- /dev/null +++ b/11-2-nginx-fast-storage.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: 1DaemonSet +metadata: + labels: + app: nginx + ssd: "true" + name: nginx-fast-storage +spec: + selector: + matchLabels: + app: nginx + ssd: "true" + template: + metadata: + labels: + app: nginx + ssd: "true" + spec: + nodeSelector: + ssd: "true" + containers: + - name: nginx + image: nginx:1.10.0 diff --git a/11-3-kuard-secret.yaml b/11-3-kuard-secret.yaml deleted file mode 100644 index 3b1e41d..0000000 --- a/11-3-kuard-secret.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: kuard-tls -spec: - containers: - - name: kuard-tls - image: gcr.io/kuar-demo/kuard-amd64:1 - imagePullPolicy: Always - volumeMounts: - - name: tls-certs - mountPath: "/tls" - readOnly: true - volumes: - - name: tls-certs - secret: - secretName: kuard-tls diff --git a/11-4-kuard-secret-ips.yaml b/11-4-kuard-secret-ips.yaml deleted file mode 100644 index ae4c6da..0000000 --- a/11-4-kuard-secret-ips.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: kuard-tls -spec: - containers: - - name: kuard-tls - image: gcr.io/kuar-demo/kuard-amd64:1 - imagePullPolicy: Always - volumeMounts: - - name: tls-certs - mountPath: "/tls" - readOnly: true - imagePullSecrets: - - name: my-image-pull-secret - volumes: - - name: tls-certs - secret: - secretName: kuard-tls diff --git a/12-1-job-oneshot.yaml b/12-1-job-oneshot.yaml new file mode 100644 index 0000000..3e62b73 --- /dev/null +++ b/12-1-job-oneshot.yaml @@ -0,0 +1,18 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: oneshot +spec: + template: + spec: + containers: + - name: kuard + image: gcr.io/kuar-demo/kuard-amd64:blue + imagePullPolicy: Always + command: + - "/kuard" + args: + - "--keygen-enable" + - "--keygen-exit-on-complete" + - "--keygen-num-to-gen=10" + restartPolicy: OnFailure diff --git a/12-2-job-oneshot-failure1.yaml b/12-2-job-oneshot-failure1.yaml new file mode 100644 index 0000000..48b428a --- /dev/null +++ b/12-2-job-oneshot-failure1.yaml @@ -0,0 +1,24 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: oneshot + labels: + chapter: jobs +spec: + template: + metadata: + labels: + chapter: jobs + spec: + containers: + - name: kuard + image: gcr.io/kuar-demo/kuard-amd64:blue + imagePullPolicy: Always + command: + - "/kuard" + args: + - "--keygen-enable" + - "--keygen-exit-on-complete" + - "--keygen-exit-code=1" + - "--keygen-num-to-gen=3" + restartPolicy: OnFailure diff --git a/12-3-job-parallel.yaml b/12-3-job-parallel.yaml new file mode 100644 index 0000000..1e78fe8 --- /dev/null +++ b/12-3-job-parallel.yaml @@ -0,0 +1,25 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: parallel + labels: + chapter: jobs +spec: + parallelism: 5 + completions: 10 + template: + metadata: + labels: + chapter: jobs + spec: + containers: + - name: kuard + image: gcr.io/kuar-demo/kuard-amd64:blue + imagePullPolicy: Always + command: + - "/kuard" + args: + - "--keygen-enable" + - "--keygen-exit-on-complete" + - "--keygen-num-to-gen=10" + restartPolicy: OnFailure diff --git a/12-4-rs-queue.yaml b/12-4-rs-queue.yaml new file mode 100644 index 0000000..6e6bc94 --- /dev/null +++ b/12-4-rs-queue.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: ReplicaSet +metadata: + labels: + app: work-queue + component: queue + chapter: jobs + name: queue +spec: + replicas: 1 + selector: + matchLabels: + app: work-queue + component: queue + chapter: jobs + template: + metadata: + labels: + app: work-queue + component: queue + chapter: jobs + spec: + containers: + - name: queue + image: "gcr.io/kuar-demo/kuard-amd64:blue" + imagePullPolicy: Always diff --git a/12-5-service-queue.yaml b/12-5-service-queue.yaml new file mode 100644 index 0000000..883cbc4 --- /dev/null +++ b/12-5-service-queue.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: work-queue + component: queue + chapter: jobs + name: queue +spec: + ports: + - port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: work-queue + component: queue diff --git a/12-6-load-queue.sh b/12-6-load-queue.sh new file mode 100755 index 0000000..facad66 --- /dev/null +++ b/12-6-load-queue.sh @@ -0,0 +1,9 @@ + +# Create a work queue called 'keygen' +curl -X PUT localhost:8080/memq/server/queues/keygen + +# Create 100 work items and load up the queue. +for i in work-item-{0..99}; do + curl -X POST localhost:8080/memq/server/queues/keygen/enqueue \ + -d "$i" +done diff --git a/12-7-job-consumers.yaml b/12-7-job-consumers.yaml new file mode 100644 index 0000000..00865bf --- /dev/null +++ b/12-7-job-consumers.yaml @@ -0,0 +1,29 @@ +apiVersion: batch/v1 +kind: Job +metadata: + labels: + app: message-queue + component: consumer + chapter: jobs + name: consumers +spec: + parallelism: 5 + template: + metadata: + labels: + app: message-queue + component: consumer + chapter: jobs + spec: + containers: + - name: worker + image: "gcr.io/kuar-demo/kuard-amd64:blue" + imagePullPolicy: Always + command: + - "/kuard" + args: + - "--keygen-enable" + - "--keygen-exit-on-complete" + - "--keygen-memq-server=http://queue:8080/memq/server" + - "--keygen-memq-queue=keygen" + restartPolicy: OnFailure