-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdeploy.yml
100 lines (98 loc) · 3.59 KB
/
deploy.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# check out all Kubernetes commands here:
# https://kubernetes.io/docs/reference/kubectl/cheatsheet/
# -----------------------------------------------------------*
# implies the use of kubernetes 1.7
# use apps/v1beta2 for kubernetes 1.8
# -----------------------------------------------------------*
apiVersion: apps/v1
kind: Deployment
metadata:
name: nodejs-demo-app
namespace: default
spec:
replicas: 4 # this is number of pods
selector:
matchLabels:
app: nodejs-demo-app
template:
metadata:
labels:
app: nodejs-demo-app
spec:
# Kubernetes run docker pull pseudo/your-image:latest under the hood
# Image field in Kubernetes resources is simply the docker image to run.
containers:
- name: nodejs-demo-app
# pulling image from my DockerHub
image: yanndocker/nodejs-demo:latest
# using if not present works well with images that has tag
# if you image is tag:lastest - use Always otherwise you
# wouldn't get the fresh version of your image
imagePullPolicy: Always
# -----------------------------------------------------------*
# It is a good practice to declare resource requests and
# limits for both memory and cpu for each container.
# This helps to schedule the container to a node that has
# available resources for your Pod, and also so that your
# Pod does not use resources that other Pods needs
# -----------------------------------------------------------*
resources:
limits:
memory: 64Mi
cpu: "250m"
requests:
memory: 32Mi
cpu: "200m"
# specify the container port
ports:
- containerPort: 30002
# -----------------------------------------------------------*
# If your image is hosted in a private docker hub repo,
# you need to specify an image pull secret in the spec field.
# -----------------------------------------------------------*
# spec:
# containers:
# - name: app
# image: pseudo/your-image:latest
# imagePullSecrets:
# - name: dockerhub-credential
# -----------------------------------------------------------*
---
apiVersion: v1
kind: Service
metadata:
name: nodejs-demo-app-entrypoint
namespace: default
spec:
# -----------------------------------------------------------*
# if you're using service type NodePort. To access you app
# and test it locally you need to listen on local port.
# you can do that by forwarding a local port to Service target
# port with name <my-service-name>
# e.g --
# kubectl port-forward service/nodejs-demo-app-entrypoint 3000:443
# -----------------------------------------------------------*
# type: NodePort
type: LoadBalancer
selector:
app: nodejs-demo-app
# The range of valid ports in kubernetes is 30000-32767
ports:
# - protocol: TCP
# port: 30002
# targetPort: 30002
# nodePort: 30002
# -----------------------------------------------------------*
# this block is for when you wanna use the type load balancer
# on your local computer or else where
# -----------------------------------------------------------*
- name: http
protocol: TCP
port: 80 # this is service port 80
targetPort: 30002
# nodePort: 30003 # this is for when using type: NodePort
- name: https
protocol: TCP
port: 443 # this is service port 443
targetPort: 30002
# nodePort: 30004 # this is for when using type: NodePort