Difference between revisions of "Kubernetes"
From John Freier
| Line 2: | Line 2: | ||
== Configurations YAML File == | == Configurations YAML File == | ||
| + | Deployment | ||
| + | - kind: Deployment | ||
| + | apiVersion: apps/v1 | ||
| + | metadata: | ||
| + | name: app-deployment | ||
| + | namespace: app-ns | ||
| + | spec: | ||
| + | replicas: 1 | ||
| + | selector: | ||
| + | matchLabels: | ||
| + | app: my-app | ||
| + | template: | ||
| + | metadata: | ||
| + | labels: | ||
| + | app: my-app | ||
| + | spec: | ||
| + | volumes: | ||
| + | - name: app-secrets-volume | ||
| + | secret: | ||
| + | secretName: my-secret | ||
| + | containers: | ||
| + | - image: ${CONTAINER_REGISTRY_URL}/${IMAGE_NAME}:${IMAGE_TAG} | ||
| + | name: my-app | ||
| + | ports: | ||
| + | - containerPort: 8080 | ||
| + | envFrom: | ||
| + | - configMapRef: | ||
| + | name: app-config | ||
| + | - secretRef: | ||
| + | name: my-secrets | ||
| + | env: | ||
| + | - name: CUSTOM_ENV_VAR | ||
| + | value: "soon_to_come" | ||
| + | volumeMounts: | ||
| + | - name: app-secrets-volume | ||
| + | mountPath: /opt/my-app/secrets-volume | ||
| + | readOnly: true | ||
| + | restartPolicy: Always | ||
| + | terminationGracePeriodSeconds: 30 | ||
Revision as of 14:14, 4 April 2022
Configurations YAML File
Deployment
- kind: Deployment
apiVersion: apps/v1
metadata:
name: app-deployment
namespace: app-ns
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
volumes:
- name: app-secrets-volume
secret:
secretName: my-secret
containers:
- image: ${CONTAINER_REGISTRY_URL}/${IMAGE_NAME}:${IMAGE_TAG}
name: my-app
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: app-config
- secretRef:
name: my-secrets
env:
- name: CUSTOM_ENV_VAR
value: "soon_to_come"
volumeMounts:
- name: app-secrets-volume
mountPath: /opt/my-app/secrets-volume
readOnly: true
restartPolicy: Always
terminationGracePeriodSeconds: 30
Service
- kind: Service
apiVersion: v1
metadata:
name: app-service
namespace: app-ns
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: my-app
Use the following option to make the service Headless, this is good when each of the pods has state and the state could be different between them. This exposes each pods ip through a DNS lookup.
Service.spec.clusterIP: None
ConfigMap
# ConfigMap Configuration
- kind: ConfigMap
apiVersion: v1
metadata:
name: app-config
namespace: app-ns
data:
CONFIG_TEMP: soon-to-come