You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

목차

개요

  • Kubernetes 배포 파일을 작성하고, 배포해 볼 것입니다.

사전조건

Kubernetes 배포 파일 작성

  • k8s-deploy.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: webflux-demo
    spec:
      selector:
        matchLabels:
          app: webflux-demo
      replicas: 3
      template:
        metadata:
          labels:
            app: webflux-demo
        spec:
          containers:
          - name: reactor-demo
            image: sooabia/webflux-demo:1.0
            ports:
            - containerPort: 8080
    --- 
    kind: Service
    apiVersion: v1
    metadata:
      name: spring-service
    spec:
      selector:
        app: webflux-demo
      ports:
      - protocol: TCP
        port: 80
        targetPort: 8080
      type: LoadBalancer
    --- 
    kind: Service
    apiVersion: v1
    metadata:
      name: redis
    spec:
      selector:
        app: redis
      ports:
      - protocol: TCP
        port: 6379
        targetPort: 6379
      type: ClusterIP

배포

  • C:\Users\Sanse\Desktop\VSCODE_WORK>kubectl apply -f k8s-deploy.yml
    deployment.apps/redis created
    deployment.apps/webflux-demo created
    service/spring-service created
    service/redis created
    
    C:\Users\Sanse\Desktop\VSCODE_WORK>kubectl get pod
    NAME                            READY   STATUS    RESTARTS   AGE
    redis-5cdcc799b8-vjlj4          1/1     Running   0          111s
    webflux-demo-7fc4f88fb4-5xmzh   1/1     Running   0          111s
    webflux-demo-7fc4f88fb4-6qhgp   1/1     Running   0          111s
    webflux-demo-7fc4f88fb4-ph75s   1/1     Running   0          111s
    
    C:\Users\Sanse\Desktop\VSCODE_WORK>kubectl get svc
    NAME             TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
    kubernetes       ClusterIP      10.96.0.1       <none>        443/TCP        3h4m
    redis            ClusterIP      10.111.176.75   <none>        6379/TCP       115s
    spring-service   LoadBalancer   10.96.172.92    localhost     80:31913/TCP   115s

서비스 확인

  • C:\Users\Sanse\Desktop\VSCODE_WORK>curl -XPOST http://localhost/link -H "Content-Type: application/json" -d "{\"link\":\"http://wiki.iisanse.com\"}"
    {"shortenedLink":"TPUqoo"}




  • No labels