Difference between revisions of "Kubernetes"
From John Freier
| Line 71: | Line 71: | ||
data: | data: | ||
CONFIG_TEMP: soon-to-come | CONFIG_TEMP: soon-to-come | ||
| + | |||
| + | Templates | ||
| + | |||
| + | To use templates, allows for values to be injected. | ||
| + | |||
| + | kind: Template | ||
| + | apiVersion: template.openshift.io/v1 | ||
| + | metadata: | ||
| + | name: my-project | ||
| + | annotations: | ||
| + | description: "This is my project" | ||
| + | tags: "java,project,other" | ||
| + | |||
| + | objects: | ||
| + | ... | ||
| + | |||
| + | # Template Parameters | ||
| + | parameters: | ||
| + | - description: "This param is an example" | ||
| + | required: true | ||
| + | name: PARAM_1 | ||
| + | - description: "To use the param use the dollar sign followed by braces." | ||
| + | required: true | ||
| + | name: IMAGE_NAME | ||
| + | |||
| + | |||
| + | Then to use the params inline, use | ||
| + | ${PARAM_1} | ||
Latest revision as of 14:18, 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
Templates
To use templates, allows for values to be injected.
kind: Template
apiVersion: template.openshift.io/v1
metadata:
name: my-project
annotations:
description: "This is my project"
tags: "java,project,other"
objects: ...
# Template Parameters
parameters:
- description: "This param is an example"
required: true
name: PARAM_1
- description: "To use the param use the dollar sign followed by braces."
required: true
name: IMAGE_NAME
Then to use the params inline, use
${PARAM_1}