Deploy the given architecture to vote namespace.
1、Create a new namespace: name = ‘vote’
kubectl create ns vote
2、
kubectl create deployment worker --image kodekloud/examplevotingapp_worker
3、
apiVersion: v1
kind: Service
metadata:
name: vote-service
namespace: vote
spec:
type: NodePort
selector:
app.kubernetes.io/name: vote-deployment
ports:
- protocol: TCP
port: 5000
targetPort: 80
nodePort: 31000
4、
kubectl create deployment vote-deployment --image kodekloud/examplevotingapp_vote:before -n vote
5、
apiVersion: v1
kind: Service
metadata:
name: redis-service
namespace: vote
spec:
selector:
app.kubernetes.io/name: redis-deployment
ports:
- protocol: TCP
port: 6379
targetPort: 6379
6、
Create new deployment, name: ‘redis-deployment’
image: ‘redis:alpine’
Volume Type: ‘EmptyDir’
Volume Name: ‘redis-data’
mountPath: ‘/data’
status: ‘Running’
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: redis-deployment
name: redis-deployment
namespace: vote
spec:
replicas: 1
selector:
matchLabels:
app: redis-deployment
template:
metadata:
labels:
app: redis-deployment
spec:
containers:
- image: redis:alpine
name: redis-deployment
volumeMounts:
- mountPath: /data
name: redis-data
volumes:
- name: redis-data
emptyDir: {}
7、
Create new deployment. name: ‘worker’
image: ‘kodekloud/examplevotingapp_worker’
status: ‘Running’
kubectl create deployment worker --image kodekloud/examplevotingapp_worker -n vote
8、
Create new service: ‘db’
port: ‘5432’
targetPort: ‘5432’
type: ‘ClusterIP’
---
apiVersion: v1
kind: Service
metadata:
name: db
namespace: vote
spec:
type: ClusterIP
ports:
- port: 5432
targetPort: 5432
selector:
app: db-deployment
9、
Create new deployment. name: ‘db-deployment’
image: ‘postgres:9.4’ and add the env: ‘POSTGRES_HOST_AUTH_METHOD=trust’
Volume Type: ‘EmptyDir’
Volume Name: ‘db-data’
mountPath: ‘/var/lib/postgresql/data’
status: ‘Running’
# kubectl create deployment db-deployment --image=postgres:9.4 --dry-run=client -o yaml -n vote > db-deployment.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: db-deployment
name: db-deployment
namespace: vote
spec:
replicas: 1
selector:
matchLabels:
app: db-deployment
template:
metadata:
labels:
app: db-deployment
spec:
containers:
- image: postgres:9.4
name: postgres
env:
- name: POSTGRES_HOST_AUTH_METHOD
value: trust
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: db-data
volumes:
- name: db-data
emptyDir: {}
10、
Create new deployment, name: ‘result-deployment’
image: ‘kodekloud/examplevotingapp_result:before’
status: ‘Running’
kubectl create deployment result-deployment --image=kodekloud/examplevotingapp_result:before -n vote
11、
port: ‘5001’
targetPort: ‘80’
NodePort: ‘31001’
---
apiVersion: v1
kind: Service
metadata:
name: result-service
namespace: vote
spec:
type: NodePort
ports:
- port: 5001
targetPort: 80
nodePort: 31001
selector:
app: result-deployment