-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.webapp-pod.yaml
66 lines (66 loc) · 3.04 KB
/
1.webapp-pod.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Create a simple web application pod hosted on port 8080
# Along with an additional container called sidecar to access resources directly from other container
# It also creates an init container which to demonstrate a initialization process before the container can get started
apiVersion: v1
kind: Pod
metadata:
name: webapp
namespace: demo
spec:
# These containers are run during pod initialization
initContainers:
- name: initializer
image: pratapgowda/demo-initializer
imagePullPolicy: IfNotPresent # Pull images only if missing in the node, Defaulted to Always
env: # Inject an environment variable directly through configuration
- name: WAIT_IN_SECS
value: "5"
volumeMounts: # Mount a file system for temporary processing at given path
- name: workdir
mountPath: "/work-dir"
containers:
# A .Net blazor application hosted on port 8080
- name: webapp
image: pratapgowda/demo-webapp:1.0
imagePullPolicy: IfNotPresent # Pull images only if missing in the node
ports:
- containerPort: 8080 # exposed ports
volumeMounts: # Mount a file system for temporary processing at given path
- name: workdir
mountPath: /usr/share/webapp/html
resources:
limits: # Maximum limits for the resource utilization
cpu: "500m" # When container reaches the limit, k8s throttles the CPU slice
memory: 1G # When container consumes more than the limit memory, its premptively removed as OOMKilled status
requests: # If node doesnt have the below requirements, pod would be in pending state till available.
cpu: "250m" # Minimum allocation of the CPU, k8s guarantees this amount from the node.
memory: 100Mi # Minimum allocation of the memory, k8s guarantees this amount from the node.
livenessProbe: # A Health probe from the container, could be an HTTP/TCP/gRPC(beta) endpoint or even a command
httpGet: # If the probe fails to be successful, the container would be deemed unhealthy and the pod would be restarted.
path: /health
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
readinessProbe: # A Probe to allow traffic to the container, if the probe fails traffic will not be routed through a service to this pod
httpGet:
path: /health
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
# A Simple container running parellely within the same pod to show case how then can talk to each other
- name: sidecar
image: busybox # by default dockerhub and latest tags are considered
imagePullPolicy: IfNotPresent # Pull images only if missing in the node
resources:
limits:
cpu: "500m"
memory: 1G
requests:
cpu: "250m"
memory: 100Mi
command: # Execute a command once the container is loaded
- sleep
- "6000"
volumes: # An empty ephemral directory definition to be mounted into the containers
- name: workdir
emptyDir: {}