Versions Compared

Key

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

Widget Connector
urlhttp://youtube.com/watch?v=-Ded7BQSkvo

Info
iconfalse
title목차

Table of Contents

개요

  • Kubernetes 배포 Manifist 파일을 작성하고, 어플리케이션을 배포해 볼 것입니다.

사전조건

배포할 환경 미리보기

Info

Image Added

Kubernetes 배포 파일 작성

  • Code Block
    themeMidnight
    titledeploy/k8s-deploy.yml
    linenumberstrue
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: redisspring-demo
    spec:
      selector:
        matchLabels:
          app: redisspring-demo
      replicas: 13
      template:
        metadata:
          labels:
            app: redisspring-demo
        spec:
          containers:
          - name: redisspring-demo
            image: redissooabia/spring-demo:1.0
            ports:
            - containerPort: 6379: 8080
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: spring-service
    spec:
      selector:
        app: spring-demo
      ports:
      - protocol: TCP
        port: 80
        targetPort: 8080
      type: LoadBalancer
    ---
      apiVersion: apps/v1
      kind: StatefulSet
     Deployment 
    metadata:
      
      name: redis
     reactor-demo 
    spec:
      
      selector:
      
        matchLabels:
      
          app: reactor-demo 
    redis
    	serviceName: redis
        replicas: 31
        template:
          metadata:
      
          labels:
      
            app: redis
          spec: reactor-demo 
    
            containers:
            - name: redis
         spec     image: redis
          containers: 
        ports:
              - containerPort: 6379
              volumeMounts:
              - name: data
                mountPath: /data
        volumeClaimTemplates:
        reactor-demo metadata:
            name: data
          image: sooabia/reactor-demo:1.0spec:
            accessModes: [ "ReadWriteOnce" ]
            portsresources:
              requests:
             -  containerPortstorage: 80801Gi
    ---  
    kind: Service 
    apiVersion: v1 
    metadata: 
      name: spring-service redis
    spec: 
      selector: 
        app: reactor-demo redis
      ports: 
      - protocol: TCP 
        port: 80 6379
        targetPort: 80806379
      type: ClusterIP

배포

  • Code Block
    languagebash
    themeMidnight
    linenumberstrue
    C:\Users\sanse\workspace\reactive-link-shortener-sample-app>kubectl apply -f k8s-deploy.yml
    deployment.apps/spring-demo created
    service/spring-service created
    statefulset.apps/redis created
    service/redis created
    
    C:\Users\sanse\workspace\reactive-link-shortener-sample-app>kubectl get pod
    NAME                           READY   STATUS    RESTARTS   AGE
    redis-0                        1/1     Running   0          26s
    spring-demo-86db8bb845-6h4g8   1/1     Running   0          26s
    spring-demo-86db8bb845-qhmj4   1/1     Running   0          26s
    spring-demo-86db8bb845-x79cl   1/1     Running   0          26s
    
    C:\Users\sanse\workspace\reactive-link-shortener-sample-app>kubectl get svc
    NAME             TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
    kubernetes       ClusterIP      10.96.0.1        <none>        443/TCP        31d
    redis            ClusterIP      10.103.235.238   <none>        6379/TCP       41s
    spring-service   LoadBalancer   10.110.19.153    localhost     80:31834/TCP   41s

서비스 확인

  • Code Block
    linenumberstrue
    C:\Users\sanse\workspace\reactive-link-shortener-sample-app>curl -XPOST http://localhost/link -H "Content-Type: application/json" -d "{\"link\":\"http://wiki.iisanse.com\"}"
    {"shortenedLink":"zMlnfI"}