-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s-deployment.yaml
48 lines (48 loc) · 1.98 KB
/
k8s-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
apiVersion: apps/v1
kind: Deployment # Type of Kubernetes resource
metadata:
name: go-hello-world # Name of the Kubernetes resource
spec:
replicas: 3 # Number of pods to run at any given time
selector:
matchLabels:
app: go-hello-world # This deployment applies to any Pods matching the specified label
template: # This deployment will create a set of pods using the configurations in this template
metadata:
labels: # The labels that will be applied to all of the pods in this deployment
app: go-hello-world
spec: # Spec for the container which will run in the Pod
containers:
- name: go-hello-world
image: istratem/go-hello-world:1.0.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080 # Should match the port number that the Go application listens on
livenessProbe: # To check the health of the Pod
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 15
timeoutSeconds: 5
readinessProbe: # To check if the Pod is ready to serve traffic or not
httpGet:
path: /readiness
port: 8080
scheme: HTTP
initialDelaySeconds: 5
timeoutSeconds: 1
---
apiVersion: v1
kind: Service # Type of kubernetes resource
metadata:
name: go-hello-world-service # Name of the resource
spec:
type: NodePort # A port is opened on each node in your cluster via Kube proxy.
ports: # Take incoming HTTP requests on port 9090 and forward them to the targetPort of 8080
- name: http
port: 9090
targetPort: 8080
selector:
app: go-hello-world # Map any pod with label `app=go-hello-world` to this service