Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titledeploy/k8s-deploy-aks.yml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
spec:
  selector:
    matchLabels:
      app: redis
  replicas: 1
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis
        ports:
        - containerPort: 6379
---
apiVersion: apps/v1
kind: Deployment 
metadata: 
  name: reactor-demo 
spec: 
  selector: 
    matchLabels: 
      app: reactor-demo 
  replicas: 3
  template:
    metadata: 
      labels: 
        app: reactor-demo 
    spec: 
      containers: 
      - name: reactor-demo 
        image: sooabia/reactor-demo:1.0
        ports: 
        - containerPort: 8080
---  
kind: Service 
apiVersion: v1 
metadata: 
  name: spring-service 
spec: 
  selector: 
    app: reactor-demo 
  ports: 
  - protocol: TCP 
    port: 80 
    targetPort: 8080
  type: LoadBalancer

...

Code Block
## Azure AKS에 배포하기
[root@workspace-vm deploy]# kubectl apply -f k8s-deploy-aks.yml 
deployment.apps/redis-deployment created
deployment.apps/reactor-demo created
service/reactor-service created
service/redis created
[root@workspace-vm deploy]# 
[root@workspace-vm deploy]# kubectl get pod
NAME                               READY   STATUS    RESTARTS   AGE
reactor-demo-8b77f949f-7fpwc       1/1     Running   0          9s
reactor-demo-8b77f949f-8lm8d       1/1     Running   0          9s
reactor-demo-8b77f949f-pltqf       1/1     Running   0          9s
redis-deployment-c899fb5b5-cx8nl   1/1     Running   0          9s
[root@workspace-vm deploy]# 
[root@workspace-vm deploy]# kubectl get svc
NAME              TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes        ClusterIP      10.0.0.1       <none>        443/TCP        3h46m
reactor-service   LoadBalancer   10.0.238.114   <pending>     80:32070/TCP   15s
redis             ClusterIP      10.0.3.79      <none>        6379/TCP       14s
[root@workspace-vm deploy]# 
[root@workspace-vm deploy]# kubectl get svc
NAME              TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
kubernetes        ClusterIP      10.0.0.1       <none>          443/TCP        3h46m
reactor-service   LoadBalancer   10.0.238.114   52.231.28.109   80:32070/TCP   48s
redis             ClusterIP      10.0.3.79      <none>          6379/TCP       47s
[root@workspace-vm deploy]# 

...

Code Block
## 삭제하기
[root@workspace-vm deploy]# kubectl delete -f k8s-deploy-aks.yml 
deployment.apps "redis-deployment" deleted
deployment.apps "reactor-demo" deleted
service "reactor-service" deleted
service "redis" deleted

...