ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Kubernetes] Argo Workflows 시작하기
    Kubernetes 2023. 12. 28. 20:22
    728x90
    반응형

    - 목차

     

    소개.

    Kubernetes 환경에서 Argo Workflow 를 구축하는 과정에 대해서 간단히 알아보려고 합니다.

     

    KinD 로 Local k8s 환경 만들기.

    https://westlife0615.tistory.com/407

     

    KinD 알아보기.

    - 목차 소개. KinD 는 "카인드" 라고 발음되며, 로컬 머신에서 쿠버네티스를 간편하게 실행할 수 있는 도구입니다. KinD 는 Kubernetes in Docker 의 약자이구요. Docker 를 활용하여 쿠버네티스 환경을 구성

    westlife0615.tistory.com

     

    위 페이지를 통해서 간단히 KinD 로 로컬 환경에 Kubernetes 를 세팅할 수 있습니다.

    위 페이지의 내용을 간단히 요약하면 아래와 같습니다.

     

    1. kubernetes config 파일 생생

    cat <<EOF> /tmp/multinode_config.yaml
    kind: Cluster
    apiVersion: kind.x-k8s.io/v1alpha4
    nodes:
    - role: control-plane
    - role: worker
    - role: worker
    - role: worker
    EOF

     

    2. KinD CLI 로 Kubernetes Cluster 생성.

    kind create cluster \
    --name test-cluster \
    --image kindest/node:v1.24.0 \
    --config /tmp/multinode_config.yaml

     

    3. kubectl 로 확인해보기.

    kubectl get node
    NAME                         STATUS   ROLES           AGE   VERSION
    test-cluster-control-plane   Ready    control-plane   22m   v1.24.0
    test-cluster-worker          Ready    <none>          21m   v1.24.0
    test-cluster-worker2         Ready    <none>          21m   v1.24.0
    test-cluster-worker3         Ready    <none>          21m   v1.24.0

     

     

    Kubernetes 내부에 Argo Workflows 생성하기.

    1. argo Namespace 와 Custom Resource Definition 을 생성.

    먼저 argo Namespace 를 생성합니다.

    그리고 Argo Workflows CRD 를 생성합니다.

    kubectl create namespace argo
    kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v3.4.4/install.yaml

     

    crd 를 조회하게 되면 아래와 같이 생성된 CRD 들이 확인할 수 있습니다.

    kubectl get crd
    NAME                                   CREATED AT
    clusterworkflowtemplates.argoproj.io   2023-11-04T01:18:48Z
    cronworkflows.argoproj.io              2023-11-04T01:18:48Z
    workflowartifactgctasks.argoproj.io    2023-11-04T01:18:48Z
    workfloweventbindings.argoproj.io      2023-11-04T01:18:48Z
    workflows.argoproj.io                  2023-11-04T01:18:48Z
    workflowtaskresults.argoproj.io        2023-11-04T01:18:48Z
    workflowtasksets.argoproj.io           2023-11-04T01:18:48Z
    workflowtemplates.argoproj.io          2023-11-04T01:18:48Z

     

    workflow-controller Deployment 가 생성되었는지 확인합니다.

    Custom Resource 들은 자신만의 Controller 가 필요합니다.

    위 커맨드를 통해서 Workflow Controller 가 생성됨을 확인해야합니다.

    kubectl -n argo get deployment
    NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
    workflow-controller   1/1     1            1           26m

     

     

    2. Argo Server 를 생성합니다.

    Argo Server 는 Argo Workflows 를 관리하기 위한 GUI Interface 입니다.

    아래와 같이 관련된 Deployment 를 생성합니다.

     

    아래의 YAML 에서 --secure=false 옵션을 추가하였습니다.

    Argo Server 는 기본적으로 https 통신을 지향하기 때문에 이를 http 프로토콜을 사용하도록 강제하기 위해서

    --secure=false 옵션이 추가됩니다.

    cat <<EOF> /tmp/argo-server-deployment.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: argo-server
      namespace: argo
    spec:
      selector:
        matchLabels:
          app: argo-server
      template:
        metadata:
          labels:
            app: argo-server
        spec:
          containers:
          - args:
            - server
            - --secure=false
            - --auth-mode=server
            env: []
            image: quay.io/argoproj/argocli:v3.4.4
            name: argo-server
            ports:
            - containerPort: 2746
              name: web
            readinessProbe:
              httpGet:
                path: /
                port: 2746
                scheme: HTTP
              initialDelaySeconds: 10
              periodSeconds: 20
            securityContext:
              allowPrivilegeEscalation: false
              capabilities:
                drop:
                - ALL
              readOnlyRootFilesystem: true
              runAsNonRoot: true
            volumeMounts:
            - mountPath: /tmp
              name: tmp
          nodeSelector:
            kubernetes.io/os: linux
          securityContext:
            runAsNonRoot: true
          serviceAccountName: argo-server
          volumes:
          - emptyDir: {}
            name: tmp
    EOF
    
    kubectl -n argo apply -f /tmp/argo-server-deployment.yaml

     

    2746 Port 를 통해서 웹 브라우저에서 접속할 수 있습니다.

     

     

    간단한 예제 실행하기.

    아래 yaml 은 Argo Workflow 에서 제공하는 간단한 예시입니다.

    cat <<EOF> /tmp/hello-world.yaml
    apiVersion: argoproj.io/v1alpha1
    kind: Workflow                  # new type of k8s spec
    metadata:
      generateName: hello-world-    # name of the workflow spec
    spec:
      entrypoint: whalesay          # invoke the whalesay template
      templates:
        - name: whalesay              # name of the template
          container:
            image: docker/whalesay
            command: [ cowsay ]
            args: [ "hello world" ]
            resources: # limit the resources
              limits:
                memory: 32Mi
                cpu: 100m
    EOF
    
    kubectl -n argo create -f /tmp/hello-world.yaml

     

    그리고 2746 Port 를 통해서 Workflow 의 실행을 확인할 수 있습니다.

     

    반응형
Designed by Tistory.