Skip to content

Commit dd8f6e5

Browse files
committed
Refactoring, rename envs to env, add a detailed CR
1 parent 9e5dc1c commit dd8f6e5

File tree

4 files changed

+164
-5
lines changed

4 files changed

+164
-5
lines changed

deploy/cr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
spec:
66
image: example-image
77
imagePullPolicy: Never
8-
appName: celery-example
8+
appName: example
99
celeryApp: 'app:celery_app'
1010
celeryVersion: "4.X"
1111
workerReplicas: 3

deploy/crd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ spec:
6969
items:
7070
description: "Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell"
7171
type: string
72-
envs:
72+
env:
7373
items:
7474
description: EnvVar represents an environment variable present in
7575
a Container.
@@ -208,7 +208,7 @@ spec:
208208
items:
209209
description: "Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell"
210210
type: string
211-
envs:
211+
env:
212212
items:
213213
description: EnvVar represents an environment variable present in
214214
a Container.

deploy/detailed_cr.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
apiVersion: celeryproject.org/v1alpha1
2+
kind: Celery
3+
metadata:
4+
name: example-celery-obj
5+
spec:
6+
image: example-image
7+
imagePullPolicy: Never
8+
imagePullSecrets:
9+
- name: dockerhub-creds
10+
appName: example-app
11+
celeryApp: 'app:celery_app'
12+
celeryVersion: "4.X"
13+
workerReplicas: 3
14+
flowerReplicas: 2
15+
workerSpec:
16+
args: [ "--loglevel", "INFO", "-Ofair", "-Q", "celery", "-c", "2" ]
17+
env:
18+
- name: STATSD_HOST
19+
valueFrom:
20+
fieldRef:
21+
apiVersion: v1
22+
fieldPath: status.hostIP
23+
- name: ENV
24+
valueFrom:
25+
configMapKeyRef:
26+
key: ENV
27+
name: global
28+
- name: FOO
29+
value: foo_value
30+
- name: APP_RELEASE_VERSION
31+
value: 8bdd66
32+
nodeSelector:
33+
disktype: ssd
34+
resources:
35+
requests:
36+
cpu: "100m"
37+
memory: "64Mi"
38+
limits:
39+
cpu: "200m"
40+
memory: "128Mi"
41+
flowerSpec:
42+
service:
43+
metadata:
44+
name: celery-example-flower
45+
namespace: default
46+
labels:
47+
app: celery-example-flower
48+
spec:
49+
type: NodePort
50+
ports:
51+
- port: 5555
52+
protocol: TCP
53+
selector:
54+
run: celery-example-flower
55+
args: [ "--loglevel", "INFO" ]
56+
nodeSelector:
57+
disktype: ssd
58+
env:
59+
- name: STATSD_HOST
60+
valueFrom:
61+
fieldRef:
62+
apiVersion: v1
63+
fieldPath: status.hostIP
64+
- name: ENV
65+
valueFrom:
66+
configMapKeyRef:
67+
key: ENV
68+
name: global
69+
- name: FOOBAR
70+
value: foobar_value
71+
- name: APP_RELEASE_VERSION
72+
value: 8bdd66
73+
resources:
74+
requests:
75+
cpu: "100m"
76+
memory: "64Mi"
77+
limits:
78+
cpu: "200m"
79+
memory: "128Mi"
80+
initContainers:
81+
- args:
82+
- -template
83+
- /configmap/nginx.conf.ctmpl:/config/nginx.conf
84+
- -log-level
85+
- trace
86+
- -once
87+
env:
88+
- name: CONSUL_ADDR
89+
valueFrom:
90+
fieldRef:
91+
apiVersion: v1
92+
fieldPath: status.hostIP
93+
- name: CONSUL_TEMPLATE_PREFIX
94+
valueFrom:
95+
configMapKeyRef:
96+
key: CONSUL_TEMPLATE_PREFIX
97+
name: global
98+
image: docker-hub.foo.bar/consul-template
99+
imagePullPolicy: Always
100+
name: consul-template
101+
resources:
102+
limits:
103+
cpu: 550m
104+
memory: 400Mi
105+
requests:
106+
cpu: 500m
107+
memory: 200Mi
108+
terminationMessagePath: /dev/termination-log
109+
terminationMessagePolicy: File
110+
volumeMounts:
111+
- mountPath: /configmap
112+
name: foo-configmap
113+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
114+
name: default-token
115+
readOnly: true
116+
volumeMounts:
117+
- mountPath: /code/settings.py
118+
name: foo-config
119+
subPath: settings.py
120+
- mountPath: /code/application/gunicorn.conf
121+
name: bar-config
122+
subPath: gunicorn.conf
123+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
124+
name: default-token
125+
readOnly: true
126+
volumes:
127+
- name: test-volume
128+
# This AWS EBS volume must already exist.
129+
awsElasticBlockStore:
130+
volumeID: "<volume id>"
131+
fsType: ext4
132+
- name: default-token
133+
secret:
134+
defaultMode: 420
135+
secretName: default-token
136+
- configMap:
137+
defaultMode: 420
138+
name: foo-configmap
139+
name: foo-configmap
140+
livenessProbe:
141+
failureThreshold: 5
142+
httpGet:
143+
path: /my-app/health
144+
port: 80
145+
scheme: HTTP
146+
initialDelaySeconds: 5
147+
periodSeconds: 20
148+
successThreshold: 1
149+
timeoutSeconds: 10
150+
readinessProbe:
151+
failureThreshold: 5
152+
httpGet:
153+
path: /my-app/health
154+
port: 80
155+
scheme: HTTP
156+
initialDelaySeconds: 5
157+
periodSeconds: 20
158+
successThreshold: 1
159+
timeoutSeconds: 10

docs/crd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ It currently supports these parameters-
1212
- `flowerReplicas` - Number of flower pods to be run. Default is 1
1313
- `workerSpec` - Worker deployment-specific parameters
1414
+ `args` - Arguments to the celery worker command. The docker image's CMD is used if this is not provided. Similar to: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
15-
+ `envs` - EnvVar represents an environment variable present in a Container. Similar to: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/
15+
+ `env` - EnvVar represents an environment variable present in a Container. Similar to: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/
1616
+ `nodeSelector` - A map of key-value pairs. For the pod/worker to be eligible to run on a node, the node must have each of the indicated key-value pairs as labels. Read more: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
1717
+ `resources` - Compute Resources required by the worker container. Cannot be updated. Read more: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
1818
- `flowerSpec` - Flower deployment specific parameters
1919
+ `args` - Arguments to the celery flower command. Similar to: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
20-
+ `envs` - EnvVar represents an environment variable present in a Container. Similar to: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/
20+
+ `env` - EnvVar represents an environment variable present in a Container. Similar to: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/
2121
+ `nodeSelector` - A map of key-value pairs. For the pod/worker to be eligible to run on a node, the node must have each of the indicated key-value pairs as labels. Read more: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
2222
+ `resources` - Compute Resources required by the worker container. Cannot be updated. Read more: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
2323
+ `service` - Service defines the template for the associated Kubernetes Service object for exposing Flower UI. Read more: https://kubernetes.io/docs/concepts/services-networking/service/

0 commit comments

Comments
 (0)