Last active
March 8, 2024 17:02
-
-
Save x95castle1/9cd0f268e20b8989ff8c88e9d27fca47 to your computer and use it in GitHub Desktop.
Overlay StatefulSet from Workload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ load("@ytt:data", "data") | |
#@ load("@ytt:yaml", "yaml") | |
#@ load("@ytt:overlay", "overlay") | |
#@ def param(key): | |
#@ if not key in data.values.params: | |
#@ return None | |
#@ end | |
#@ return data.values.params[key] | |
#@ end | |
#@ def overlayvolumes(): | |
#@overlay/match by=overlay.subset({"kind":"StatefulSet"}), expects="0+" | |
--- | |
spec: | |
template: | |
#@overlay/match missing_ok=True | |
volumeClaimTemplates: #@ param("volumeclaimtemplate") | |
spec: | |
#@overlay/match missing_ok=True | |
volumemounts: #@ param("volumemounts") | |
#@ end | |
#@ def delivery(): | |
--- | |
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: web | |
spec: | |
selector: | |
matchLabels: | |
app: nginx | |
serviceName: "nginx" | |
replicas: 3 | |
minReadySeconds: 10 | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
terminationGracePeriodSeconds: 10 | |
containers: | |
- name: nginx | |
image: registry.k8s.io/nginx-slim:0.8 | |
ports: | |
- containerPort: 80 | |
name: web | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: jeremy | |
spec: | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: nginx-deployment | |
labels: | |
app: nginx | |
spec: | |
replicas: 3 | |
selector: | |
matchLabels: | |
app: nginx | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
containers: | |
- name: nginx | |
image: nginx:1.14.2 | |
ports: | |
- containerPort: 80 | |
#@ end | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: my-cm | |
labels: my-label | |
data: | |
delivery.yml: #@ yaml.encode(overlay.apply(delivery(),overlayvolumes())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@data/values | |
--- | |
params: | |
volumeclaimtemplate: | |
- metadata: | |
name: zookeeper-vol | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 8Gi | |
storageClassName: rbd | |
volumemounts: | |
- name: www | |
mountPath: /usr/share/nginx/html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment