Skip to content

Instantly share code, notes, and snippets.

@parmou
Created May 21, 2021 21:52
Show Gist options
  • Save parmou/046d83b01dae1e11b0d5d033eaffe77a to your computer and use it in GitHub Desktop.
Save parmou/046d83b01dae1e11b0d5d033eaffe77a to your computer and use it in GitHub Desktop.
Deployment YAML manifest
## Set the API endpoint used to create the Deployment resource.
apiVersion: apps/v1
## Define the type of the resource.
kind: Deployment
## Set the parameters that make the object identifiable, such as its name, namespace, and labels.
metadata:
annotations:
labels:
app: go-helloworld
name: go-helloworld
namespace: default
## Define the desired configuration for the Deployment resource.
spec:
## Set the number of replicas.
## This will create a ReplicaSet that will manage 3 pods of the Go hello-world application.
replicas: 3
## Identify the pods managed by this Deployment using the following selectors.
## In this case, all pods with the label `go-helloworld`.
selector:
matchLabels:
app: go-helloworld
## Set the RollingOut strategy for the Deployment.
## For example, roll out only 25% of the new pods at a time.
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
## Set the configuration for the pods.
template:
## Define the identifiable metadata for the pods.
## For example, all pods should have the label `go-helloworld`
metadata:
labels:
app: go-helloworld
## Define the desired state of the pod configuration.
spec:
containers:
## Set the image to be executed inside the container and image pull policy
## In this case, run the `go-helloworld` application in version v2.0.0 and
## only pull the image if it's not available on the current host.
- image: pixelpotato/go-helloworld:v2.0.0
imagePullPolicy: IfNotPresent
name: go-helloworld
## Expose the port the container is listening on.
## For example, exposing the application port 6112 via TCP.
ports:
- containerPort: 6112
protocol: TCP
## Define the rules for the liveness probes.
## For example, verify the application on the main route `/`,
## on application port 6112. If the application is not responsive, then the pod will be restarted automatically.
livenessProbe:
httpGet:
path: /
port: 6112
## Define the rules for the readiness probes.
## For example, verify the application on the main route `/`,
## on application port 6112. If the application is responsive, then traffic will be sent to this pod.
readinessProbe:
httpGet:
path: /
port: 6112
## Set the resource requests and limits for an application.
resources:
## The resource requests guarantees that the desired amount
## CPU and memory is allocated for a pod. In this example,
## the pod will be allocated with 64 Mebibytes and 250 miliCPUs.
requests:
memory: "64Mi"
cpu: "250m"
## The resource limits ensure that the application is not consuming
## more than the specified CPU and memory values. In this example,
## the pod will not surpass 128 Mebibytes and 500 miliCPUs.
limits:
memory: "128Mi"
cpu: "500m"
## Set the API endpoint used to create the Service resource.
apiVersion: v1
## Define the type of the resource.
kind: Service
## Set the parameters that make the object identifiable, such as its name, namespace, and labels.
metadata:
labels:
app: go-helloworld
name: go-helloworld
namespace: default
## Define the desired configuration for the Service resource.
spec:
## Define the ports that the service should serve on.
## For example, the service is exposed on port 8111, and
## directs the traffic to the pods on port 6112, using TCP.
ports:
- port: 8111
protocol: TCP
targetPort: 6112
## Identify the pods managed by this Service using the following selectors.
## In this case, all pods with the label `go-helloworld`.
selector:
app: go-helloworld
## Define the Service type, here set to ClusterIP.
type: ClusterIP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment