k8s-deploy.yml
Code Block |
---|
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-deployment
spec:
selector:
matchLabels:
app: spring
replicas: 3
template:
metadata:
labels:
app: spring
spec:
containers:
- name: spring
image: sooabia/spring-reactor-redis:9
ports:
- containerPort: 8080
- name: redis
image: redis:4.0.8-alpine
ports:
- containerPort: 6379
---
kind: Service
apiVersion: v1
metadata:
name: spring-service
spec:
selector:
app: spring
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
|
Kubernetes에 배포
Code Block |
---|
[root@docker-compose-vm deploy]# kubectl create -f k8s-deploy.yml
deployment.apps/spring-deployment created
service/spring-service created
|
Kubernetes 배포 결과 확인
Code Block |
---|
[root@docker-compose-vm deploy]# kubectl get pod
NAME READY STATUS RESTARTS AGE
spring-deployment-668745fb84-5nc98 2/2 Running 0 6m50s
spring-deployment-668745fb84-h4prv 2/2 Running 0 6m50s
spring-deployment-668745fb84-s2b8k 2/2 Running 0 6m50s
[root@docker-compose-vm deploy]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 42d
spring-service LoadBalancer 10.0.161.34 23.97.55.191 80:30621/TCP 5m10s
|