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
    titlek8s-deploy.yml
    linenumberstrue
    ---
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: redisspring-demo
      spec:
        selector:
          matchLabels:
            app: redisspring-demo
      replicas: 3
      replicastemplate: 1
        templatemetadata:
          metadatalabels:
            labelsapp: spring-demo
        spec:
          appcontainers:
     redis
         - specname: spring-demo
             containers:image: sooabia/spring-demo:1.0
            - nameports: redis
            -  imagecontainerPort: 8080
    ---
    kind: redisService
    apiVersion: v1
    metadata:
      name: spring-service
    spec:
      selector:
        app: spring-demo
      ports:
      - protocol: TCP
        port: 80
        targetPort: 8080
     - containerPorttype: 6379LoadBalancer
    ---
      apiVersion: apps/v1
      kind: DeploymentStatefulSet
      metadata:
        name: webflux-demoredis
      spec:
        selector:
          matchLabels:
            app: webflux-demoredis
    	serviceName: redis
        replicas: 31
        template:
          metadata:
            labels:
              app: webflux-demoredis
          spec:
            containers:
            - name: reactor-demoredis
              image: sooabia/webflux-demo:1.0
    redis
              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 6379
              volumeMounts:
              - name: data
                mountPath: /data
        volumeClaimTemplates:
        - metadata:
            name: data
          spec:
            accessModes: [ "ReadWriteOnce" ]
            resources:
              requests:
               storage: 1Gi
    --- 
    kind: Service
    apiVersion: v1
    metadata:
      name: redis
    spec:
      selector:
        app: redis
      ports:
      - protocol: TCP
        port: 6379
        targetPort: 6379
      type: ClusterIP

...

  • Code Block
    languagebash
    themeMidnight
    linenumberstrue
    C:\Users\Sansesanse\Desktop\VSCODE_WORK>kubectlworkspace\reactive-link-shortener-sample-app>kubectl apply -f k8s-deploy.yml
    deployment.apps/redis created
    deployment.apps/webfluxspring-demo created
    service/spring-service created
    statefulset.apps/redis created
    service/redis created
    
    C:\Users\Sansesanse\Desktop\VSCODE_WORK>kubectlworkspace\reactive-link-shortener-sample-app>kubectl get pod
    NAME                            READY   STATUS    RESTARTS   AGE
    redis-5cdcc799b8-vjlj40                        1/1     Running   0          111s26s
    webfluxspring-demo-7fc4f88fb486db8bb845-5xmzh6h4g8   1/1     Running   0          111s26s
    webfluxspring-demo-7fc4f88fb486db8bb845-6qhgpqhmj4   1/1     Running   0          111s26s
    webfluxspring-demo-7fc4f88fb486db8bb845-ph75sx79cl   1/1     Running   0          111s26s
    
    C:\Users\Sansesanse\Desktop\VSCODE_WORK>kubectlworkspace\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        3h4m31d
    redis            ClusterIP      10.111103.176235.75238   <none>        6379/TCP       115s41s
    spring-service   LoadBalancer   10.96110.17219.92153    localhost     80:3191331834/TCP   115s41s

서비스 확인

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