<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jinwon on Medium]]></title>
        <description><![CDATA[Stories by Jinwon on Medium]]></description>
        <link>https://medium.com/@vincent841?source=rss-d72fdecaf747------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F3kOt_M5tEI9ATAvXb5nVg.jpeg</url>
            <title>Stories by Jinwon on Medium</title>
            <link>https://medium.com/@vincent841?source=rss-d72fdecaf747------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:10:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vincent841/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AWS EKS 버전 업데이트]]></title>
            <link>https://medium.com/hatiolab/aws-eks-%EB%B2%84%EC%A0%84-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8-fb35e7595d9f?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb35e7595d9f</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[version-update]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Fri, 13 Jan 2023 10:42:07 GMT</pubDate>
            <atom:updated>2023-01-15T07:35:19.730Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/hatiolab/%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C-%EC%84%9C%EB%B9%84%EC%8A%A4-%EC%86%8C%EA%B0%9C-a39b5e86afc6">Things-Factory 웹 프레임워크</a> 기반의 식음료 공장 자동화 시스템인 <a href="https://operatochef.com/">Operato Chef</a> 서비스를 비롯해서 많은 다양한 서비스를 쿠버네티스 환경에서 배포되도록 도입하면서 서비스 개발과 백엔드 프레임워크 개발에만 집중하고 있다보니 어느날 AWS EKS 콘솔에서 다음과 같은 메시지를 보고 말았습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*J3XujlNI0J1xFDJUe31DJg.png" /></figure><p>EKS 클러스터 생성과 관리는 사실 담당하시는 다른 분이 있기도 했고, 한번 생성해두면 신경쓸 것이 없을 것이라고 예상한 것과 달리 아마존 콘솔은 저에게 왜 지금까지 이렇게 낡은 버전을 사용하고 있다고 혼을 내고 있었습니다. 저기 옆에 있는 ‘Update now’ 버튼을 무심코 누르려다 현재 서비스 중인 클러스터에 문제가 발생(생각만 해도 끔직..)할 것을 우려해 버전 업데이트에 앞서위해 필요한 사항을 아래 문서에서 검토해보고 깊은 고민에 빠집니다.</p><p><a href="https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html#kubernetes-1.22">Amazon EKS Kubernetes versions</a></p><p>버전 별로 빼곡하게 작성되어 있는 체크리스트들은 서비스 배포 위주로만 사용하던 저에게는 너무 생소해서 겁도 나기 시작합니다. 애드온들의 버전을 업데이트해야하고 사용하는 매니페스트들 버전 업데이트 후에 제거되는 것들을 검토해야 하고.. 저희가 사용하고 있는 버전은 1.21이지만 최종 버전은 1.24이고, 버전 업데이트는 마이너 버전을 1씩 올라가면 진행해야 하기 때문에 총 3번의 업데이트 수행이 필요합니다.(1.21 -&gt; 1.22 -&gt; 1.23 -&gt; 1.24)</p><p>우선 1.24는 컨테이너 엔진에서 DockerShim이 제거되는 등 변화가 심해서 우선 1.23까지 업데이트를 수행하기로 하고, 문제가 발생될 것을 대비해서 클러스터백업 및 복원 방안을 먼저 확보하기로 합니다.</p><h3>Velero</h3><p><a href="https://velero.io/">Velero</a></p><p>AWS EKS에서 자체 클러스터 백업 서비스가 있을 것 같았지만 공식 문서에서도 Velero라는 서비스를 사용하도록 유도하고 있습니다. 클러스터 버전 업데이트 후 문제 발생 시 빠르게 복원 가능한 환경을 먼저 구성하기로 합니다.</p><p><a href="https://aws.amazon.com/ko/blogs/containers/backup-and-restore-your-amazon-eks-cluster-resources-using-velero/">Backup and restore your Amazon EKS cluster resources using Velero | Amazon Web Services</a></p><p>기본적으로 쿠버네티스 클러스터는 클러스터에 배포되어 있는 다양한 오브젝트들을 매니페스트로 구성하고 있으며 이러한 구성은 etcd라고 하는 서비스를 통해서 노드 별로 동일한 데이터가 배포되어 관리되도록 하고 있습니다.</p><h4>etcd</h4><p>etcd는 ‘엣시디’라고 발음하며머신의 분산된 시스템 또는 클러스터의 설정 공유, 서비스 검색 및 스케줄러 조정을 위한 일관된 <a href="https://www.redhat.com/ko/topics/open-source/what-is-open-source">오픈소스</a>, 분산형 키-값 저장소입니다. 쿠버네티스의 기본 데이터 저장소로 사용되고 있으며 etcd는 분산형 합의 기반 시스템이고, 데이터의 유실에 민감한 데이터 관리를 용이하게 수 있습니다. etcd는 다음과 같은 특성을 가지고 있습니다.</p><ul><li>사용 편이성: 명확하게 정의된 사용자 API(gRPC 기반)</li><li>보안: 자동화된 TLS 기반 통신 제공</li><li>속도: 10,000 writes/sec</li><li><em>신뢰성</em>: Raft 분산 합의(consensus) 알고리즘을 기반으로 하는 분산 서비스 제공</li></ul><h4>쿠버네티스에서 etcd</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*ZM74_8SIjb2sJjcIzoc4Qg.png" /><figcaption>ectd in k8s</figcaption></figure><ul><li>k8s 클러스터의 복구와 일종의 중요 데이터를 저장하는 데이터베이스</li><li>etcd를 사용하면 Kubernetes 마스터가 검색 서비스를 지원하여 배포된 애플리케이션이 서비스에 포함될 수 있음을 선언할 수 있습니다.</li><li>클러스터 내의 모든 configuration 정보가 포함되어 있음.</li><li><strong>etcd의 특징 중 하나인 분산형 서비스의 성격으로 인해서 클러스터 간 데이터 복제본을 만들며 데이터 원본과 복제본 간의 데이터 신뢰성을 확보</strong>.(etct을 사용하는 가장 큰 이유)</li></ul><h4>Velero 동작 원리</h4><p>Velero를 설명하다 etcd를 길게 설명하니 의아하실 수도 있지만 Velero는 이 etcd에 저장되어 있는 데이터들을 백업하고 복원하는 기능을 수행합니다. 왜냐하면 쿠버네티스 클러스터에 포함되어 있는 모든 오브젝트 정보는 모두 etcd에 있으니까요.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*YYZKade3VDPddGaWA35Clg.png" /><figcaption>velero integration with k8s for backup</figcaption></figure><ul><li>사용자는 로컬 컴퓨터에 Velero를 설치합니다. 설치 단계에서 Velero는 로컬에 클라이언트를 설치할 뿐만 아니라 쿠버네티스 클러스터에 백업 및 복원을 수행하는 Pod를 배포합니다.</li><li>Velero가 이러한 백업 및 복원을 수행 가능한 이유는 쿠버네티스에서 정의된 CRD(Custom Resource Definition)를 사용하기 때문입니다. 이를 통해 etcd에 저장도 가능해지고 규격에 정해져있는 기능 외에 다른 기능 수행이 가능해집니다.</li></ul><h4>Velero 설치</h4><p>Velero 설치 공식 홈페이지에 설명이 잘되어 있지만, 요약본은 다음과 같습니다.</p><ol><li>백업된 데이터를 저장하기 위한 S3 버킷을 생성합니다.</li></ol><pre>BUCKET=&lt;YOUR_BUCKET&gt;<br>REGION=&lt;YOUR_REGION&gt;<br>aws s3api create-bucket \<br>    --bucket $BUCKET \<br>    --region $REGION \<br>    --create-bucket-configuration LocationConstraint=$REGION</pre><p>2. velero에서 사용하기 위한 IAM User를 생성합니다.</p><pre>aws iam create-user --user-name velero<br><br>cat &gt; velero-policy.json &lt;&lt;EOF<br>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ec2:DescribeVolumes&quot;,<br>                &quot;ec2:DescribeSnapshots&quot;,<br>                &quot;ec2:CreateTags&quot;,<br>                &quot;ec2:CreateVolume&quot;,<br>                &quot;ec2:CreateSnapshot&quot;,<br>                &quot;ec2:DeleteSnapshot&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:DeleteObject&quot;,<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:AbortMultipartUpload&quot;,<br>                &quot;s3:ListMultipartUploadParts&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::${BUCKET}/*&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:ListBucket&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::${BUCKET}&quot;<br>            ]<br>        }<br>    ]<br>}<br>EOF<br><br><br>aws iam put-user-policy \<br>  --user-name velero \<br>  --policy-name velero \<br>  --policy-document file://velero-policy.json<br><br>aws iam create-access-key --user-name velero<br><br>{<br>    &quot;AccessKey&quot;: {<br>        &quot;UserName&quot;: &quot;velero&quot;,<br>        ...<br>    }<br>}</pre><p>3. 생성 후에 access id와 key는 별도의 파일에 다음과 같이 저장합니다. 여기서는 credentials-velero라는 파일명으로 저장했습니다. 해당 키는 차후 velero 설치에 사용됩니다.</p><pre>[default]<br>aws_access_key_id=.....<br>aws_secret_access_key=.....</pre><p>4. Velero를 로컬 PC에 설치합니다. 설치 방법은 다음의 문서를 참조하면 됩니다.</p><p><a href="https://velero.io/docs/v1.3.0/basic-install/">Basic Install</a></p><p>맥 사용자이고 HomeBrew를 사용 중이시라면 간단하게 다음과 같이 설치 가능합니다.</p><pre>brew install velero</pre><p>5. 위 설치가 끝나면 기본적으로 velero cli 사용이 가능합니다. 우리는 먼저 사용 중인 클러스터에 velero-plugin을 설치해야 합니다. 이 때 미리 만들어둔 S3 버킷과 ‘credentials-velero’ 파일을 사용하게 됩니다.</p><pre>velero install \<br>    --provider aws \<br>    --plugins velero/velero-plugin-for-aws:v1.6.0 \<br>    --bucket $BUCKET \<br>    --backup-location-config region=$REGION \<br>    --snapshot-location-config region=$REGION \<br>    --secret-file ./credentials-velero</pre><p>아 하지만 쉽게 될리가 만무하네요. 다음과 같은 에러가 발생합니다.</p><pre>An error occurred: exec plugin: invalid apiVersion &quot;client.authentication.k8s.io/v1alpha1&quot;</pre><p>해당 에러는 aws-cli 버전 문제로서 다음과 같이 버전을 업데이트합니다.</p><pre>curl &quot;https://awscli.amazonaws.com/AWSCLIV2.pkg&quot; -o &quot;AWSCLIV2.pkg&quot;<br>sudo installer -pkg AWSCLIV2.pkg -target /<br><br># update-kubeconfig 실행<br>mv ~/.kube/config ~/.kube/config.bk<br>aws eks update-kubeconfig --region ${AWS_REGION}  --name ${EKS_CLUSTER_NAME}</pre><p>이후 velero install을 하면 문제 없이 설치가 완료됩니다. velero가 클러스터에 정상적으로 설치가 되었는지 확인을 합니다.</p><pre>~/projects/hatiolab/aws-cloud/eks-backup/velero<br>❯ kubectl get pod -n velero<br>NAME                      READY   STATUS    RESTARTS   AGE<br>velero-794478b9c5-rfbrc   1/1     Running   0          24h<br><br>~/projects/hatiolab/aws-cloud/eks-backup/velero<br>❯ kubectl get all -n velero<br>NAME                          READY   STATUS    RESTARTS   AGE<br>pod/velero-794478b9c5-rfbrc   1/1     Running   0          24h<br><br>NAME                     READY   UP-TO-DATE   AVAILABLE   AGE<br>deployment.apps/velero   1/1     1            1           2d2h<br><br>NAME                                DESIRED   CURRENT   READY   AGE<br>replicaset.apps/velero-794478b9c5   1         1         1       2d2h</pre><h4>클러스터 백업</h4><p>정상적인 동작을 확인한 이후에는 다음과 같이 velero cli를 사용해서 백업을 생성합니다.</p><pre>velero backup-location get<br>NAME      PROVIDER   BUCKET/PREFIX              PHASE       LAST VALIDATED                  ACCESS MODE   DEFAULT<br>default   aws        s3-test-bucket             Available   2023-01-11 13:48:10 +0900 KST   ReadWrite     true<br><br>velero backup create {백업명}<br>Backup request &quot;backup-name&quot; submitted successfully.<br>Run `velero backup describe backup-name` or `velero backup logs backup-name` for more details.</pre><p>백업은 배포된 어플리케이션의 개수 등에 영향을 받겠지만 그렇게 많은 시간이 소요되지 않습니다. (1분 이내 소요) 진행 사항은 다음 명령어로 확인 가능합니다.</p><pre>velero backup describe backup-name</pre><p>S3에 배포된 데이터의 예는 다음과 같습니다. etcd에 저장된 오브젝트들의 매니페스트 정보들고 함께 volume snapshot도 저장됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*vOKEzqO9jUuKm70xuG7GYQ.png" /></figure><h4>클러스터 복원</h4><p>이렇게 저장된 백업은 다음 명령을 통해서 복원이 가능합니다.</p><pre>velero restore create --from-backup &lt;BACKUP-NAME&gt;</pre><h4>Velero 제거</h4><p>Velero Cli는 OS의 프로그램 제거 방법을 통해서 제거하면 되고, 클러스터에 설치된 플러그인은 다음과 같은 명령어로 제거가 가능합니다.</p><pre>kubectl delete namespace/velero clusterrolebinding/velero<br>kubectl delete crds -l component=velero</pre><h3>EKS 버전 업데이트 관련 정리</h3><p>원래 이 글의 목적이었던, 버전 업데이트를 진행하면서 저와 같이 처음 진행하시는 분이 보면 좋을 만한 내용을 이제 정리해 보고자 합니다.</p><h4><strong>AWS Load Balancer Controller 설치</strong></h4><p>AWS Load Balancer Controller는 EKS에서 AWS의 ELB(Elastic Load Balancer)를 관리하는 컨트롤러로서 우리가 서비스나 인그레스를 생성하면 이와 연동되어 ELB가 생성되고 연동되는 것을 관리하는 AWS에서 제공하는 별도의 컨트롤러입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*xC0THAGDhlvpux9BBIZ5Qg.png" /><figcaption><a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/how-it-works/">https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/how-it-works/</a></figcaption></figure><p>Load Balancer Controller 다음과 같은 쿠버네티스 버전에 따라서 그에 부합되는 버전이 설치되어 있어야 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*VhYrgbrp4BR1fDdYXwfL5Q.png" /><figcaption><a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/">https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/deploy/installation/</a></figcaption></figure><p>제 경우에 1.21에서 1.22로 EKS 버전을 업데이트하면서 Load Balancer Controller가 문제가 되었습니다. 기존에 설치 버전이 2.2.0이었고, 보시다시피 버전이 부합되지 않기 때문이니다. 이와 관련한 부분은 뒤에 다시 자세히 설명 드립니다.</p><p>이러한 Load Balancer Controller는 문서에 자세히 설명되어 있지만 요약본으로 다음과 같이 정리합니다.</p><ol><li>IAM OIDC를 생성합니다. Load Balancer나 EBS CSI 드라이버처럼 커스텀으로 구현된 패키지가 클러스터 전체를 범위로 동작하도록 하기 위해서는 ServiceAccount를 생성해야 하는데 생성에 앞서 클러스터에서 한번 무조건 생성해야 하는 것이 IAM. OIDC입니다.</li></ol><pre>eksctl utils associate-iam-oidc-provider \<br>    --region ap-northeast-2 \<br>    --cluster test-eks-cluster-2 \<br>    --approve</pre><p>2. Load Balancer Controller의 ServiceAccount를 생성하기 위한 과정은 다음과 같습니다.</p><p>다음과 같이 policy를 생성해서 등록합니다. VERSION 부분은 변경이 가능합니다.</p><pre>export LBC_VERSION=release-2.4.3<br>curl -o iam_policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/${LBC_VERSION}/docs/install/iam_policy.json<br>aws iam create-policy \<br>    --policy-name AWSLoadBalancerControllerIAMPolicy \<br>    --policy-document file://iam_policy.json</pre><p>3. 생성된 Policy를 사용해서 다음과 같이 ServiceAccount를 생성합니다. 여기서는 간단하게 eksctl을 통해서 생성합니다. (aws cli를 통해서 단계적으로 생성도 가능합니다.)</p><pre>eksctl create iamserviceaccount \<br>  --cluster {클러스터명} \<br>  --namespace kube-system \<br>  --name aws-load-balancer-controller \<br>  --attach-policy-arn arn:aws:iam::{ACCOUNTID}:policy/AWSLoadBalancerControllerIAMPolicy \<br>  --override-existing-serviceaccounts \<br>  --approve</pre><p>4. TargetGroupBinding CRDs를 설치합니다.</p><pre>kubectl apply -k &quot;github.com/aws/eks-charts/stable/aws-load-balancer-controller/crds?ref=master&quot;<br><br>kubectl get crd<br><br># 실행 예<br>NAME                                         CREATED AT<br>eniconfigs.crd.k8s.amazonaws.com             2022-09-21T01:32:52Z<br>ingressclassparams.elbv2.k8s.aws             2022-09-21T05:15:30Z<br>securitygrouppolicies.vpcresources.k8s.aws   2022-09-21T01:32:55Z<br>targetgroupbindings.elbv2.k8s.aws            2022-09-21T05:15:30Z</pre><p>5. Helm Chart를 사용하여 aws-loadbalancer-controller 배포합니다.</p><pre># 최신 버전으로 배포<br>helm upgrade -i aws-load-balancer-controller \<br>    eks/aws-load-balancer-controller \<br>    -n kube-system \<br>    --set clusterName={클러스터명} \<br>    --set serviceAccount.create=false \<br>    --set serviceAccount.name=aws-load-balancer-controller<br><br># 특정 버전으로 배포할 경우<br>helm upgrade -i aws-load-balancer-controller \<br>    eks/aws-load-balancer-controller \<br>    -n kube-system \<br>    --set clusterName={클러스터명} \<br>    --set serviceAccount.create=false \<br>    --set serviceAccount.name=aws-load-balancer-controller \<br>    --set image.tag=&quot;${LBC_VERSION}&quot; \<br>    --version=&quot;${LBC_CHART_VERSION}&quot;</pre><p>다음과 같이 정상 배포 여부를 확인할 수 있습니다.</p><pre>❯ kubectl -n kube-system rollout status deployment aws-load-balancer-controller<br>deployment &quot;aws-load-balancer-controller&quot; successfully rolled out</pre><h4>AWS Load Balancer Controller가 helm으로 설치가 안되면..</h4><p>정상적으로 설치가 되지않고 다음과 같은 메시지가 발생할 수 있습니다. (제가 그랬습니다. ㅠㅠ)</p><pre>Release &quot;aws-load-balancer-controller&quot; does not exist. Installing it now.<br>Error: rendered manifests contain a resource that already exists. Unable to continue with install: Deployment &quot;aws-load-balancer-controller&quot; in namespace &quot;kube-system&quot; exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key &quot;app.kubernetes.io/managed-by&quot;: must be set to &quot;Helm&quot;; annotation validation error: missing key &quot;meta.helm.sh/release-name&quot;: must be set to &quot;aws-load-balancer-controller&quot;; annotation validation error: missing key &quot;meta.helm.sh/release-namespace&quot;: must be set to &quot;kube-system&quot;</pre><p>해당 에러 메시지는 기존의 설치와 helm을 통한 설치와 달라서 배포가 되지 않는 이슈입니다. 특히, 이전에 설치 버전이 오래된 경우에 발생할 수 있습니다. 저의 경우에는 이전 설치가 helm 으로 삭제도 안되었기 때문에 방법을 찾아야 했습니다. 하지만 아무거나 시험삼아 지우기도 난감하기도 합니다.</p><p>에러 메시지에 명시된 오브젝트를 ‘kubectl delete’로 지워보기로 합니다.</p><pre>Deployment &quot;aws-load-balancer-controller&quot; in namespace &quot;kube-system&quot; exists and cannot be imported into the current release: </pre><p>계속해서 다른 오브젝트가 에러로 발생합니다. 아마도 기존에 설치된 대부분의 오브젝트가 문제가 되는 것 같습니다. 그래서 다음과같이 모든 오브젝트를 지우고 나서야 설치가 가능했습니다.</p><pre>kubectl delete service aws-load-balancer-webhook-service -n kube-system<br>kubectl delete clusterrole aws-load-balancer-controller-role<br>kubectl delete clusterrolebinding aws-load-balancer-controller-rolebinding<br>kubectl delete role/aws-load-balancer-controller-leader-election-role -n kube-system<br>kubectl delete rolebinding/aws-load-balancer-controller-leader-election-rolebinding -n kube-system<br>kubectl delete deploy aws-load-balancer-controller -n kube-system<br>kubectl delete MutatingWebhookConfiguration aws-load-balancer-webhook<br>kubectl delete ValidatingWebhookConfiguration aws-load-balancer-webhook</pre><h4>EKS 버전에 부합되지 않는 AWS Load Balancer Controller가 설치되어 있지 않으면..</h4><p>기존에 Controller의 버전은 2.2였으나, 해당 버전은 EKS 1.22에서는 지원되지 않습니다. EKS 버전 업데이트 이후에는 정상적으로 동작하는 것처럼 보였지만 이후 몇 번의 테스트 이후에 ingress를 기반으로 하는 모든 서비스들이 정상적으로 운용되지 않고, 503 에러를 뱉어내고 있었습니다.(맙소사) 하지만 서비스를 port-forwarding해 보면 모든 Deployment들은 정상 동작하고 ingress 부분만 동작하지 않고 있었습니다.</p><p>ingress를 시험 삼아 생성해 보지만 자동으로 생성되어 할당하는 도메인이 없습니다.</p><pre>❯ kubectl get ingress<br>NAME                 CLASS    HOSTS                                                              ADDRESS                                                                       PORTS   AGE<br>operatochef          &lt;none&gt;   hub.operatochef.com,cook.operatochef.com,airflow.operatochef.com   k8s-default-operatoc-db23a0c437-216608399.ap-northeast-2.elb.amazonaws.com    80      136d<br>sticky-operatochef   &lt;none&gt;   shiny.operatochef.com                                              k8s-default-stickyop-18f271ec9f-1217625963.ap-northeast-2.elb.amazonaws.com   80      112d<br>test-ingress         &lt;none&gt;   *                                                                                                                                                80      2m</pre><p>해당 에러를 Load Balancer 이슈로 잠정적으로 판단하고 여러 로그들을 살펴본 결과, 다음 명령으로 Load Balancer가 정상이 아님을 확인할 수 있었습니다.</p><pre>&gt; kubectl -n kube-system rollout status deployment aws-load-balancer-controller<br>wait for xxxxxx</pre><p>문제 해결의 방법은 앞에서 언급한 방법으로 컨트롤러 버전을 EKS 1.22에서 지원되는 2.4 이상으로 올리는 것입니다. 컨트롤러 버전을 올리는 방법 ‘AWS Load Balancer Controller 설치’을 참조하시면 됩니다.</p><h4>애드온 업데이트가 안되면..</h4><p>EKS는 기본적으로 다음 그림과 같이 3개의 애드온을 기본적으로 가지고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ECNMhS-aAMT6mJdBZ3zb3A.png" /></figure><p>Amazon EKS에서는 Amazon VPC CNI plugin for Kubernetes 추가 기능으로 기본 VPC 네트워킹을 지원합니다.</p><ul><li>탄력적 네트워크 인터페이스(네트워크 인터페이스)를 생성하고 Amazon EC2 노드에 연결합니다.</li><li>프라이빗 IPv4 또는 IPv6 주소를 VPC에서 각 pod 및 서비스에 할당합니다. pods 및 서비스는 VPC 네트워크에서와 마찬가지로 pod 내부에 동일한 IP 주소가 있습니다.</li></ul><p>CoreDNS는 클러스터 내에서 관리되는 도메인 네임 서비스로서 클러스터 내에 배포된 파드와 서비스들의 이름을 기반으로 하는 이름 기반의 네트워킹을 가능하게 합니다. 클러스터 내의 다른 서비스에 연결하고자 할 때 IP 대신 서비스 이름을 통해서 통신이 가능합니다.</p><p>kube-proxy는 노드마다 생성되어 노드의 네트워크 규칙을 유지 관리합니다.. 이 네트워크 규칙이 내부 네트워크 세션이나 클러스터 바깥에서 파드로 네트워크 통신을 할 수 있도록 해준다. 주요 네트워크 관련 이슈 발생 시, 주요 단서를 제공할 수 있는 로그를 확인할 수 있습니다.</p><p>이러한 애드온들도 EKS 버전에 따라 업데이트를 수행해야 합니다. 간단히는 다음과 같이 콘솔을 통해서 업데이트가 가능하지만 저의 경우에는 버전이 낮아서 그런지 바로 업데이트가 되지 않고 에러가 발생했습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*KTTKgtkcuJWjRdOGbOiJJw.png" /><figcaption>콘솔을 통한 애드온 업데이트 예</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*u07yjcjC_g1P6G97aMAZcQ.png" /><figcaption>콘솔을 통한 애드온 업데이트 실패 예</figcaption></figure><p>이 경우에는 eksctl을 통한 강제 업데이트를 수행해야 합니다. 각 애드온 별로 설치 방법을 아래와 같이 공유합니다.</p><p><strong>CoreDNS 설치</strong></p><pre># 업데이트<br>eksctl update addon --name coredns --version vA.B.C --cluster {클러스터명} --force<br><br># 확인<br>kubectl describe deployment coredns --namespace kube-system | grep Image | cut -d &quot;/&quot; -f 3</pre><p>CoreDNS 버전은 다음을 참고합니다.</p><p><a href="https://docs.aws.amazon.com/eks/latest/userguide/managing-coredns.html">Working with the CoreDNS Amazon EKS add-on</a></p><p><strong>VPC-CNI 설치</strong></p><p>VPC -CNI의 경우, AWS 전용 별도의 애드온이기 때문에 별도의 ServiceAccount Role의 생성이 필요합니다.</p><pre># 버전 확인<br>aws eks describe-addon-versions --kubernetes-version {EKS버전} --addon-name vpc-cni \<br>    --query &#39;addons[].addonVersions[].{Version: addonVersion, Defaultversion: compatibilities[0].defaultVersion}&#39; --output table<br><br># 업데이트<br>aws eks update-addon --cluster-name {클러스터명} --addon-name vpc-cni --addon-version {애드온버전} \<br>    --service-account-role-arn arn:aws:iam::{ACCOUNT ID}:role/{Role Name} --configuration-values &#39;{}&#39; --resolve-conflicts PRESERVE</pre><p>버전 및 Role 생성 방법은 다음을 참고합니다.</p><p><a href="https://docs.aws.amazon.com/eks/latest/userguide/managing-vpc-cni.html">Working with the Amazon VPC CNI plugin for Kubernetes Amazon EKS add-on</a></p><p><strong>kube-proxy 설치</strong></p><pre># 버전 확인<br>aws eks describe-addon-versions --kubernetes-version {EKS 버전} --addon-name kube-proxy \<br>    --query &#39;addons[].addonVersions[].{Version: addonVersion, Defaultversion: compatibilities[0].defaultVersion}&#39; --output table<br><br># 업데이트<br>eksctl update addon --name kube-proxy --version {애드온 버전} --cluster {클러스터명} --force</pre><p>버전과 관련한 정보는 다음을 참고합니다.</p><p><a href="https://docs.aws.amazon.com/eks/latest/userguide/managing-kube-proxy.html">Updating the kube-proxy add-on</a></p><h4>노드가 생성 후 Not Started에서 Ready로 변경되지 않을 경우</h4><p>다음과 같은 에러를 확인하면,</p><pre>runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized</pre><p>다음 명령을 수행합니다.</p><pre>kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml</pre><p>해당 이슈는 복제 클러스터에서 발생했는데, 이슈는 해결되었지만 원인 분석이 미흡합니다. 차후 현상이 발생되고 이슈가 정리되면 업데이트를 하도록 하겠습니다.</p><h4>EKS 1.23를 위해서는 aws-ebs-csi-driver를 설치해야 합니다.</h4><p>자세한 문서는 다음 두 문서를 참조하면 됩니다.</p><p>Service Account 생성</p><p><a href="https://docs.aws.amazon.com/eks/latest/userguide/csi-iam-role.html">Creating the Amazon EBS CSI driver IAM role</a></p><p>EBS CSI 애드온 설치</p><p><a href="https://docs.aws.amazon.com/eks/latest/userguide/managing-ebs-csi.html">Managing the Amazon EBS CSI driver as an Amazon EKS add-on</a></p><p>요약본은 다음과 같습니다.</p><pre># IAMSERVICE 생성(미리 Policy를 생성해야 합니다. Policy<br>eksctl create iamserviceaccount \<br>  --name ebs-csi-controller-sa \<br>  --namespace kube-system \<br>  --cluster {클러스터명} \<br>  --attach-policy-arn {ServiceAccount Policy}\<br>  --approve \<br>  --role-only \<br>  --role-name AmazonEKS_EBS_CSI_DriverRole(이름 변경 가능)<br><br># AddOn 생성<br>eksctl create addon --name aws-ebs-csi-driver --cluster {클러스터명} --service-account-role-arn arn:aws:iam::{Account ID}:role/AmazonEKS_EBS_CSI_DriverRole --force<br># Addon 확인<br>eksctl get addon --name aws-ebs-csi-driver --cluster {클러스터명}</pre><p>Service Account Role은 <a href="https://us-east-1.console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy">AmazonEBSCSIDriverPolicy</a>를 Policy를 설정하고, trust relation은 다음과 같이 구성합니다.</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Federated&quot;: &quot;arn:aws:iam::111122223333:oidc-provider/oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRoleWithWebIdentity&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:aud&quot;: &quot;sts.amazonaws.com&quot;,<br>          &quot;oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:sub&quot;: &quot;system:serviceaccount:kube-system:ebs-csi-controller-sa&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><h4>EKS 1.23 업데이트 이후 PV 관련 이슈</h4><p>EKS 1.23 업데이트 이후 PV를 사용하고 있는 배포 서비스들이 중단되는 현상이 발생했습니다. EKS 1.23으로 업데이트 이후에 가장 큰 변화는 AWS EBS CSI 드라이버가 설치되어 있어야 EBS를 기반으로 하는 PV와 같은 서비스 사용이 가능합니다. 해당 부분은 문서를 정독해서 인지하고 있었음에도 발생을 했고 원인을 찾아야 합니다.</p><p>aws-ebs-csi-driver와 관련한 리소스들은 다음과 같이 확인이 가능합니다.</p><pre>kubectl get all -l app.kubernetes.io/name=aws-ebs-csi-driver -n kube-system<br>NAME                                      READY   STATUS    RESTARTS   AGE<br>pod/ebs-csi-controller-8475d6c779-74fgj   6/6     Running   0          9h<br>pod/ebs-csi-controller-8475d6c779-zjgkr   6/6     Running   0          9h<br>pod/ebs-csi-node-2h4rm                    3/3     Running   0          19h<br>pod/ebs-csi-node-qx4r8                    3/3     Running   0          19h<br><br>NAME                                  DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR              AGE<br>daemonset.apps/ebs-csi-node           2         2         2       2            2           kubernetes.io/os=linux     19h<br>daemonset.apps/ebs-csi-node-windows   0         0         0       0            0           kubernetes.io/os=windows   19h<br><br>NAME                                 READY   UP-TO-DATE   AVAILABLE   AGE<br>deployment.apps/ebs-csi-controller   2/2     2            2           19h<br><br>NAME                                            DESIRED   CURRENT   READY   AGE<br>replicaset.apps/ebs-csi-controller-8475d6c779   2         2         2       19h</pre><p>리소스 관련 로그 확인은 다음과 같습니다.</p><pre># 컨트롤러 포드 로그를 확인하여 탑재 실패 원인을 파악합니다. 생성 중에 볼륨에서 장애가 발생하면 ebs-plugin 및 csi-provisioner 로그를 참조하세요. 다음 명령을 실행하여 ebs-plugin 컨테이너 로그를 검색합니다.<br>kubectl logs deployment/ebs-csi-controller -n kube-system -c ebs-plugin<br>kubectl logs daemonset/ebs-csi-node -n kube-system -c ebs-plugin<br><br># csi-provisioner 컨테이너 로그를 검색<br>kubectl logs deployment/ebs-csi-controller -n kube-system -c csi-provisioner<br><br># csi-attacher 컨테이너 로그를 검색<br>kubectl logs deployment/ebs-csi-controller -n kube-system -c csi-attacher</pre><p>위의 로그들을 확인 중에 deployment/ebs-csi-controller 관련 로그에서 다음과 같은 메시지를 확인합니다.</p><pre>kubectl logs deployment/ebs-csi-controller -n kube-system -c ebs-plugin<br>...<br>AccessDenied: Not authorized to perform sts:AssumeRoleWithWebIdentity\n\tstatus code: 403, </pre><p>로그의 생략된 부분을 보면 EC2의 인스턴스를 찾을 수 없다고 하면서 에러 메시지를 출력합니다. 에러 메시지에서 가장 큰 단서는 sts:AssumeRoleWithWebIdentity로서 IAM Role에서 ServiceAccount의 Trust Relation 설정에 있어서 필요한 Action 입니다. 이를 통해서 해당 이슈는 ServiceAccount Role과 관련되어 있음을 알 수 있습니다. Service Account는 클러스터에 배포되어 AWS의 다른 자원들을 기반으로 하는 리소스에 접근하기 위해서 sts:AssumeRoleWithWebIdentity를 사용합니다.</p><p>다시 ebs-csi-controller 드라이버의 ServiceAccount를 확인합니다.</p><pre>kubectl describe sa ebs-csi-controller-sa -n kube-system<br>Name:                ebs-csi-controller-sa<br>Namespace:           kube-system<br>Labels:              app.kubernetes.io/component=csi-driver<br>                     app.kubernetes.io/managed-by=EKS<br>                     app.kubernetes.io/name=aws-ebs-csi-driver<br>                     app.kubernetes.io/version=1.14.0<br>Annotations:         eks.amazonaws.com/role-arn: arn:aws:iam::{ACCOUNTID}:role/IBEXEKS_EBS_CSI_DriverRole<br>Image pull secrets:  &lt;none&gt;<br>Mountable secrets:   ebs-csi-controller-sa-token-9pnjv<br>Tokens:              ebs-csi-controller-sa-token-9pnjv<br>Events:              &lt;none&gt;</pre><p>Annotations 부분에 Role의 이름이 의도하지 않은 이름이 들어가 있었습니다. EKS 업데이트 관련 시험을 위해서 별도의 복제 클러스터를 생성하고 시험을 했었는데 이 때 생성된 Role이 여기에 등록되어 있습니다. 영문은 모르겠지만 제가 저지른 일이겠네요.</p><p>우선 SA Role을 다음 명령으로 수정할 필요가 있습니다</p><pre>kubectl annotate serviceaccount -n kube-system ebs-csi-controller-sa eks.amazonaws.com/role-arn: arn:aws:iam::{ACCOUNT ID}:role/AmazonEKS_EBS_CSI_DriverRole</pre><p>이렇게 수정을 했으나 문제는 해결되지 않습니다. 조금 더 문서를 확인해보니 SA 변경 내용이 적용되면 드라이버를 재설치하거나 혹은 일부 Pod를 재시작할 필요가 있습니다. 드라이버 재설치보다는 Pod를 재시작하는 것이 간단하기 때문에 이전에 4개의 Pod를 지워서 강제로 재시작합니다.</p><pre>AME                                      READY   STATUS    RESTARTS   AGE<br>pod/ebs-csi-controller-8475d6c779-74fgj   6/6     Running   0          9h<br>pod/ebs-csi-controller-8475d6c779-zjgkr   6/6     Running   0          9h<br>pod/ebs-csi-node-2h4rm                    3/3     Running   0          19h<br>pod/ebs-csi-node-qx4r8                    3/3     Running   0          19h</pre><p>이슈가 된 서비스들이 모두 정상적으로 시작되는 것을 확인할 수 있었습니다.</p><h3>끝으로</h3><p>처음 EKS 업데이트를 진행하면서 다음과 같은 사항들을 확인할 수 있었습니다.</p><ol><li>쿠버네티스는 리소스 별로 잘 고립화되어 있어서 실제로 문제가 발생하고 수정하는 과정에서 다른 리소스에 영향이 거의 없이 수정이 가능했습니다.</li><li>Velero를 사용한 백업 및 복원은 매우 편리합니다만, 제가 이번에 확인하면서 EKS 버전이나 애드온이 다른 상황에서 복원될 경우 문제가 있었습니다. 또한 클러스터를 완벽하게 복원해서 시험을 하는 일은 생각보다 많은 시간이 소요됩니다. 간단하게 데브 클러스터나 혹은 새로 클러스터를 생성할 경우 애드온이나 플러그인 버전 정도만 동일하게 맞추고 일부 주요 서비스만 배포해서 업데이트를 시험해 보는 것이 좋을 것 같습니다.</li><li>EKS 업데이트 이전 AWS 문서를 확인해서 주요 변경점을 체크하는 것은 필수로 보입니다.</li><li>애드온의 버전도 지속적으로 체크를 해서 업데이트를 해야 할 것으로 보입니다. 또한 노드 그룹도 EKS 버전이 업데이트 될 때마다 업데이트를 해야 합니다.</li><li>쿠버네티스는 거의 3개월 단위로 마이너 버전이 올라가고 이에 맞추어 EKS도 거의 동일하게 버전을 릴리즈하기 때문에 EKS 운용 시 필수적으로 버전 관리를 해야 합니다.</li><li>AWS 공식 문서에는 친절하게 가이드 문서에서 eksctl, Amazon Console, aws cli와 같이 구분해서 설치 방법을 설명하고 있습니다. 가장 간단한 방법은 eksctl을 사용하는 것입니다. eksctl은 복잡한 과정의 경우 Cloud Formation을 사용해서 자동화하여 여러 개의 리소스 생성을 하나의 명령어로 가능하게 해 줍니다. 하지만, 이러한 자동화가 리소스 중복 등의 문제가 발생하면 어차피 생성 과정을 파악해야 하기 때문에 aws cli를 통해서 단계적으로 진행하는 것이 저에게는 더 과정을 이해하는데 도움이 많이 되었습니다.</li><li>Fargate는 이러한 버전 관리에 자유로워보이는데 아직 정보가 없어서 장단점 판단이 안서네요.</li></ol><p>이번 업데이트를 계기로 저에게는 쿠버네티스에 대한 이해, 특히 kube-system 네임스페이스에 배포되는 핵심적인 배포 서비스들을 이해할 수 있는 계기가 되었고, 관련해서 더 깊은 이해가 필요함 또한 느꼈습니다. 다음 글에서는 쿠버네스티스의 kue-system 네임스페이스에 대한 조금 더 깊은 이야기와 디버깅에 대해서 이야기를 하고자 합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb35e7595d9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/aws-eks-%EB%B2%84%EC%A0%84-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8-fb35e7595d9f">AWS EKS 버전 업데이트</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Forecast Service Automation]]></title>
            <link>https://medium.com/hatiolab/forecast-service-automation-4475f8c1b68d?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/4475f8c1b68d</guid>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[aws-forecast]]></category>
            <category><![CDATA[predictive-analytics]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Fri, 26 Aug 2022 09:01:33 GMT</pubDate>
            <atom:updated>2022-08-26T09:02:51.269Z</atom:updated>
            <content:encoded><![CDATA[<h3>Forecast Automation?</h3><p>AWS Forecast is a service that analyzes and predicts time series data, and can predict future data by selecting various time series algorithms based on data sets named Dataset Group with time series data located in S3 buckets. For more information about these AWS Forecast service, please refer to the following documents.</p><p><a href="https://medium.com/hatiolab/how-to-predict-time-series-data-using-aws-forecast-e72caa329e8d">How to predict time series data using AWS Forecast</a></p><p>AWS Forecast has four management points as shown in the following figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aDEV-gVJ2ycBDYkR.png" /><figcaption>Components of AWS Forecast Service</figcaption></figure><ul><li>Dataset S3 Bucket &amp; Forecast Data Export Bucket</li><li>Datasets(Target Dataset, Related Dataset, Item Metadata)</li><li>Predictor</li><li>Forecast Data</li></ul><p>For each management point, there are individual requirements for AWS Forecast, and there are many considerations to manually handle them. For each management point, there are individual requirements for AWS Forecast, and there are many considerations to manually handle them. Also, each task like “Dataset Import”, “Predictor Creation”, and “Forecast Data Generation” takes tens of minutes to hours, so it seems inefficient for humans to continuously perform these tasks manually. So, I think the area that needs the most automation is the creation of the 4 management entities mentioned above in the case of the AWS Forecast service.</p><h3>AWS Step Functions</h3><p>The following factors should be required regarding creating tasks to build Forecast Automation servcie.</p><ul><li>Multiple Dataset Groups should be created and processed in parallel, and resources should be added automatically when necessary.</li><li>Since the automatic creation of these resources only intermittently occurs in response to user-generated events, there is no need to provision the resources all the time.</li><li>Since the creation of some resources takes several tens of minutes to several hours, it should be possible to continuously monitor the creation of resources during long execution times.</li></ul><p>In order to perform them, we considered various services that can perform aperiodic tasks, like Airflow, Jenkins but those services are required to provision our own resoureces, So we needed to look for other manasged service and became interested in AWS Step Functions based on AWS Lambda Function, one of serverless services in AWS introduced in the following exmaple.</p><p><a href="https://docs.aws.amazon.com/forecast/latest/dg/tutorial-cloudformation.html">Automating with AWS CloudFormation</a></p><p>Since it is implemented based on a Lambda function, one of AWS’s representative serverless services, it can be operated for every user request without the need to provision resources all the time, and can actively respond to multiple requests. In addition, the Lambda Function-based AWS STep Function has also been upgraded to perform the state machine creation task based on the GUI in it, away from the existing text-based machine design, So the difficulty of AWS Step Functions state machine creation has been improved dramatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZgiYIjErnGOaIIo16gJG9Q.png" /><figcaption>State Machine Editor of AWS Step Functions</figcaption></figure><p>AWS Step Functions can hanle all exceptions that may occur in Lambda Functions and when some exceptions occurs in a Lambda Function as one of tasks in AWS Step Functions, the function can be retryed after a certain time without proceeding to the next Lambda function. In the case of a time-consuming operation such as creating a predictor using these functions, when the Lambda function is called, an exception is raised for a specific state of the predictor, so that the Lambda function can repeat the retry until the predictor is normally created. And it can be configured to allowed us to build Forecast Automation service without provisioning and waiting for resources for a long time.</p><p>Another advantage of AWS Step Functions is that you can use functions of various services provided by AWS except Lambda functions without any custom code. For example, if you want to send an email to a user when a specific error occurs, you can implement it through AWS’s SNS service, some error messages can be sent to the user by e-mail by placing a SNS Publish task which is already prepared in AWS Step Functions as the folloiwng.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*gkLheE8yn1Lq97prt3WOsw.png" /><figcaption>Simple State Machine with SNS publish task in AWS Step Fuctions</figcaption></figure><h3>Forecast Automation API</h3><p>Here’s a full overview of the capabilities of Forecast Automation currently configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efVQdX9oHFj2er6PM6oryA.png" /><figcaption>The overview of Forecast Automation</figcaption></figure><ul><li>Users can create AWS Forecast’s Dataset Group, Predictor, and Forecast using the predefined Rest API.</li><li>Rest API consists of the following three API types: New, Predictor and Forecast</li></ul><p>The configuration of State Machine of AWS Step Functions to build our internal Forecast Automation service is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UCme59sZ9t33Yo9WJK8q_Q.png" /><figcaption>AWS Step Functions State Machine of Forecast Service</figcaption></figure><ul><li>This state machine is processed by branching into “New”, “Predictor”, and “Forecast” based on the API type of Body of Rest API.</li><li>Depending on the processing result of each task (AWS Lambda Function), it proceeds to the next step or if an exception occurs, it ends after processing an error message through the “Notify-Failed” task.</li><li>In the case of a time-consuming task such as the “Create-Predictor”, it runs periodically by “Retry on errors” condition of Step Functions as follows until its resource is ready.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*D-4IrVpmWThLZxX01gw_5g.png" /><figcaption>“Retry on erros” of AWS Step Functions in “Create-Predictor” task</figcaption></figure><p><strong>“New” API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8Rbp9YVRfG-XBs1aBL9lA.png" /></figure><p><strong>New API</strong> is an API for creating a new Dataset Group. Through this API, we can create a new Dataset Group and Dataset Import, Predictor and Forecast export data automatically.</p><p>An example of API input data for calling these New APIs is as the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2cc2ca170ff1255b202e6492e2549eb/href">https://medium.com/media/a2cc2ca170ff1255b202e6492e2549eb/href</a></iframe><h4>S3 structure for Dataset Group</h4><p>In order to create an AWS Forecast Service Dataset Group through the <strong>New API</strong>, dasasets must be configured in the following structure in the designated S3 Bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*v94AYaMQEyAwZS_pQyDiyA.png" /><figcaption>Predefined S3 dataset directory structure for Forecast Automation</figcaption></figure><ul><li>User should configure the dataset related files by referring to the above structure before executing the New API.</li><li>User should store s time series data in target, related and metadata respectively in <strong>Datasets</strong> directory.</li><li>The <strong>Exports</strong> directory is where forecast data is automatically stored when a Forecast is created. Usually, a directory name is created like “export_ dataset_name_2022_07_19_10_26_04” and the result data is stored inside.</li><li><strong>dataset.json</strong> is automatically generated during the New API execution step.</li></ul><h4>“Predictor” API</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_uB_iw99j3aJwrD4hAHk6Q.png" /></figure><p><strong>Predictor</strong> <strong>API </strong>is used to create additional predictors within the already created Dataset Group. Predictors can be created through various parameters described in the following document.</p><p><a href="https://docs.aws.amazon.com/forecast/latest/dg/API_CreatePredictor.html">CreatePredictor</a></p><p>An example of API input data for calling a <strong>Predictor API</strong> is as the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c215efabb721568ba43379f530ae7620/href">https://medium.com/media/c215efabb721568ba43379f530ae7620/href</a></iframe><h4>“Forecast” API</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9nE1jkjNjxKxasoOzREvOA.png" /></figure><p>Forecast is used to create additional Forecast within the already created Dataset Group. Forecast can be created through various parameters described in the following document.</p><p><a href="https://docs.aws.amazon.com/forecast/latest/dg/API_CreateForecast.html">CreateForecast</a></p><p>An example of API input data for calling a <strong>Forecast API</strong> is as the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0ae87e1537156907bb2370350479eb1/href">https://medium.com/media/c0ae87e1537156907bb2370350479eb1/href</a></iframe><h3>Wrap Up</h3><ul><li>The automation of the resource creation process like Forecast Automation service does not occur by any scheduled jobs, and is triggered based on user’s request in most cases, so AWS Step Functions, one of serverless service in AWS, can be an good choice.</li><li>In order to build a state machine of AWS Step Function, an individual implementation of a Lambda function is required, and it is also essential to set up an IAM role for accessing other AWS resources.</li><li>Both the deployment process of Lambda Function and the deployment process of State Mahchine must be accompanied in order to perform the automated deployment of AWS Step Function’s State Machine.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4475f8c1b68d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/forecast-service-automation-4475f8c1b68d">Forecast Service Automation</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to predict time series data using AWS Forecast]]></title>
            <link>https://medium.com/hatiolab/how-to-predict-time-series-data-using-aws-forecast-e72caa329e8d?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/e72caa329e8d</guid>
            <category><![CDATA[cloud-plattform]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[aws-forecast]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 12:03:24 GMT</pubDate>
            <atom:updated>2022-07-01T12:04:33.256Z</atom:updated>
            <content:encoded><![CDATA[<h3>Time series forecasting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1xmYB99dJ-AqXAu6f6Z5w.png" /><figcaption>source: <a href="https://mariazork.github.io/deep%20learning/2020/06/20/metro-traffic-forecasting.html">https://mariazork.github.io/deep%20learning/2020/06/20/metro-traffic-forecasting.html</a></figcaption></figure><p>Time series forecasting is one of the most applied data science techniques in business, finance, supply chain management, production and inventory planning. Many forecasting problems involve a time component and therefore require extrapolation or time series forecasting of time series data. Time series prediction is also an important area in machine learning (ML) and can be thrown around as a supervised learning problem. You can apply ML methods such as Regression, Neural Networks, Support Vector Machines, Random Forests, and XGBoost. Forecasting involves taking a model that fits past data and using it to predict future observations.</p><p>Time series forecasting means predicting or forecasting the future value over a period of time. This involves developing models based on historical data and applying them to observe and guide future strategic decisions. The future is predicted or estimated based on what has already happened. A time series adds a time-order dependency between observations. This dependency is a construct and constraint that provides a source of additional information. Before discussing time series forecasting methods, let’s define time series forecasting in more detail.</p><p>Time series forecasting starts with a historical time series. Analysts examine historical data and identify time-resolved patterns such as trends, seasonal patterns, periodic patterns, and regularities. Many areas within an organization, including marketing, finance, and sales, use some form of time series forecasting to evaluate possible technology costs and consumer demand. Models for time series data can take many forms and represent different stochastic processes. Time series analysis is about understanding data sets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-ZYTPrViQs66CClF.jpg" /><figcaption>source: <a href="https://polzinben.github.io/Time-Series-Forecasting/">https://polzinben.github.io/Time-Series-Forecasting/</a></figcaption></figure><p>Time series analysis consists of analyzing time series data to extract meaningful statistical and other characteristics of the data. Time series forecasting is the use of a model to predict future values ​​based on previously observed values.<br>There are three aspects of predictive modeling:</p><ul><li>Dataset ingestion and preprocessing: Data collected to illustrate the problem of known relationships between inputs and outputs.</li><li>Model training: Algorithms used on sample data to create a model that can be used continuously in the future.</li><li>Prediction: Use the trained model on new data of unknown output.</li></ul><h3>AWS Forecast?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*DocGr4qToZ2k54SUa_pXVA.png" /><figcaption>AWS Forecast</figcaption></figure><p>Amazon Forecast (Forecast) is a fully managed service that uses machine learning to deliver highly accurate forecasts.</p><p>Based on the same technology used at Amazon.com, Forecast uses machine learning to combine time series data with additional variables to build forecasts. Forecast requires no machine learning experience to get started. You only need to provide historical data, plus any additional data that you believe may impact your forecasts.</p><p>We are reviewing several time-series data prediction engines to develop a forecasting system based on various data generated through the construction of logistics and factory automation systems, and as part of this review, we are verifying the overall usage and performance of AWS Forecast.</p><h3>Overall configuration of AWS Forecast</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WUA7Fa3Pqi_B3aRM7rrl_A.png" /><figcaption>AWS Forecast main components</figcaption></figure><p>AWS Forecast is designed to create one <strong>Dataset Group</strong> by default for data forecasting. A Dataset Group manages <strong>Datasets</strong> composed of Target Dataset, Related Dataset, and Item Metadata and can generate a <strong>Predictor</strong> based on these datasets. Prediction data can be generated based on the Predictor, and the prediction data is generated based on an object called <strong>Forecast</strong>.</p><p>And also, you can choose the forecast domain of you data in AWS Forecast and you need to prepare the data schema required by each domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IcnstBXki5RyX5CTPBkMmQ.png" /><figcaption>Forecasting domains of AWS Forecast</figcaption></figure><h3>3 Datasets: Target, Related and Metadata</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N1JmFlqUnlflzRMcTTXfvQ.png" /><figcaption>The example of datasets</figcaption></figure><ul><li>Composed of Target, Related and Metdata and Target dataset is a mandatory but the ther two are optional.</li><li>Referencing data formatted in csv and parquet from S3 for each dataset</li><li>Can assign a file name or a directory name for each dataset and you can add files in the directory without the rule of the file name if you assigned a directory name for a dataset.</li><li>To apply the changed dataset for Predictor or Forecast, you should perform the data import for each dataset. It’ll take from several minutes to tens of minutes to import a dataset.</li><li>Target Dataset: Specifies the data that is metric for the prediction, along with a timestamp and an item id. Timestamp support two formats like (yyyy-MM-dd or yyyy-MM-dd hh-mm-ss)</li><li>Related Dataset(optional): Specifies external variables which are related with the target value(ie. a product price or a weather information)</li><li>Item Metadata(optional): Specifies additional information of item_id defined in Target Dataset. (ie. information such as size and color if the target tiem is a bag)</li><li>Shoud define the data schema when you create a dataset and you need to store data only for the columns defined in the schema in S3, and the order of the columns must be the same as the schema as well.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*d2xv9evNyKKAMIAor2JKLg.png" /><figcaption>The example of Target Dataset</figcaption></figure><ul><li>Not enough to store new data in the specific S3 location and you should perform a dataset import.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*xvXiHvVtX-mPdjBu44vNdQ.png" /></figure><h3>Predictor</h3><p>Predictor is a model created through training by a predefined algorithm based on imported datasets. Once the Predictor is created, it can generate forecast results for various quantiles options. Predictor has the following characteristics:</p><ul><li>Create a prediction model through model training using all datasets of Dataset Group.</li><li>Can select one of the various models available(ARIMA, CNN_QR, DeepAR+, ETS, NPTS, Prophet) for training. You can refer to the detail infomation of each algorithem in the following.</li></ul><p><a href="https://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-choosing-recipes.html">Amazon Forecast Algorithms</a></p><ul><li>AWS Forecast recommend AutoML or AutoPredictor though you can choose a algorithm to generate an predictor. You can see the following warning if you try to select one specific algorithm, not AutoPredictor.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmZmqHSxv7bZ_TB_Q9Dgjg.png" /><figcaption>The warning of AutoPredictor unselected</figcaption></figure><ul><li>I could get better backtest results when using AutoPredictor than the specific one like DeepAR+.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lbo0DoqTjLxgn-hYFYjTHQ.png" /><figcaption>Backtest result comparison</figcaption></figure><ul><li>AutoPredictor can select the most suitable algorithm for the current dataset, so AWS Forecast recommend to choose AutoPredictor as a predcition algorithm but it takes more than twice the training time compared to singe algorithm selection.</li><li>You need to set forecast frequency(minutes to years), forecast horizon(prediction time window based on forecast frequency) and forecast quantile(P10, P50, P90) except algorithms.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsGX1j7Tvd49leQrSdpxKw.png" /><figcaption>the example of a generated predictor</figcaption></figure><ul><li>If you need to retrain the predictor using new data, you need to generate new dataset import and create a new predictor. A newly created Predictor always refers to the most recently imported dataset.</li></ul><h3>Forecast</h3><p>Forecast generates the result of prediction with the predefined quantiles. The result usually stores into S3 bucket The length of the forecast period is just the forecast horizon beginning from the last timestamp of the target dataset.</p><ul><li>Perform future data prediction using the generated predictor and export the result to the specific S3 bucket.</li><li>Should assign forecast quantiles like P10, P90, mean and P50 as well as the pre-created predicgtor. You can see the quantiles of the predicted values in the exported result of the forecast.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*tIIvinwYTmMv-AE5IiT0PQ.png" /><figcaption>Forecast quantiles as Forecst setting</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*1aX00oJfGMaWMY8x6WfOtA.png" /><figcaption>The example of exported forecast results</figcaption></figure><ul><li>Can also get the forecast results using QueryForecast as well.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*JKS7PKAwiisx-Hfg86DJYA.png" /><figcaption>QueryForecast Settings</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*S0WVL-URP38Dvu2V6hE7vg.png" /><figcaption>The example of QueryForecast</figcaption></figure><h3>Price</h3><h4>Major billing point for each component</h4><ul><li>Dataset: the size of the stored data</li><li>Predictor: the training time</li><li>Forecast: the forecast data points(# of forecast values for a specific date)</li></ul><p>Please refer to the following table about more datail information</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbBZm5sxZ9b-Dh3yhri6Bw.png" /><figcaption>Price table of AWS forecast</figcaption></figure><h3>Limitations</h3><p><a href="https://docs.aws.amazon.com/forecast/latest/dg/limits.html">Guidelines and Quotas</a></p><p>Some limitation items can be adjustable by requesting to AWS.</p><h4>Dataset Import</h4><ul><li># of files in S3: up to 10,000</li><li>the accumulated file size in S3: 30GB</li><li>the maximum rows of a dataset: 3 billion</li></ul><h4>Predictor</h4><ul><li># of backtest window: 5</li><li># of time series data: 5,000,000</li><li>maximum forecast horizon: the lesser of 500 data points or 1/3 of the target time series dataset length for <strong>AutoPredictor, CNN-QR, DeepAR+</strong> or the lesser of 500 data points or the length of the target time series dataset minus one for <strong>ETS, NPTS, Prophet, ARIMA</strong>.</li></ul><h3>What is Quantile?</h3><p>Quantile is cut points dividing the rangeof a probability distribution into continuous intervals with equal probabilities, or dividing the observations in a sample in the same way. There is one fewer quantile than the number of groups created.</p><p>The forecast value at P75 is much higher than the value predicted at P50 because the P75 forecast is expected to meet the demand 75% of the time, whereas the P50 forecast is only expected to meet the demand 50% of the time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qFpT9s-nGBgs4zpg.jpg" /><figcaption>P50 vs. P70</figcaption></figure><p>In example, using a lower quantile in terms of demand forecasting means choosing a lower value for forecast selection. When such a choice is necessary, it can be selected when it is advantageous when an actual error occurs to bring the price lower than to evaluate the demand high in the market. If the cost when the product is in stock because the product is not selling well due to the high demand is higher than the cost when the product is in stock because the demand is low and the product is not sold even if the demand is low, the low quantile value can be selected as the prediction value in the prediction model. In the opposite case, the higher quantile can be selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i5vIY5GqoE28PRn_Ad0PBA.png" /><figcaption>The example of forcast results based on quantiles</figcaption></figure><h3>Model Optimization</h3><ul><li>Need to judge over-forecasting or under-forecasting considering the characteristics of the business</li><li>Optimization is performed through a segmented distribution to solve problems related to under or over-forecasting</li><li>If you create and compare multiple models, compare wQL based on the same number of displacements.</li><li>Regarding backtest, 5 backtests can be selected. Selecting multiple backtest windows will help you decide to create a more accurate model in the future.</li></ul><h4>Backtest</h4><p>Backtest is an internal test to increase the accuracy of the model and tune the internal parameters when training the predictor. When the backtest is executed, the forecast automatically divides the time series data into a training set and a test set, and calculates accuracy-related indicators using the window set for the backtest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_osRt5SNuBLn-kST5jzdaw.png" /><figcaption>Backtest Scenarios</figcaption></figure><h3>The next: Forecast Automation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*UbddGZf98Rj_6kuGD83cPg.png" /><figcaption>The example of Forecast automation</figcaption></figure><p>I’ve been designing and implementing an MLOps architecture based on the AWS Forecast engine using serverless services like AWS Lambda. I would like to share this with you in the near future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e72caa329e8d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/how-to-predict-time-series-data-using-aws-forecast-e72caa329e8d">How to predict time series data using AWS Forecast</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to migrate RDS to Redshift using AWS Database Migration Service]]></title>
            <link>https://medium.com/hatiolab/how-to-migrate-rds-to-redshift-using-aws-database-migration-service-36bb155d2925?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/36bb155d2925</guid>
            <category><![CDATA[database-migration]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[redshift]]></category>
            <category><![CDATA[rds]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Thu, 16 Jun 2022 08:59:01 GMT</pubDate>
            <atom:updated>2022-06-16T11:11:27.564Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/495/0*5W7IYLKzgxW3H_kh.png" /><figcaption>AWS Database Migration Service(DMS)</figcaption></figure><p>AWS has Database Migration Service(DMS) which can migrate data between different kind of database like RDS(Relational Database Service), S3, Redshift, and so on. DMS can support many kinds of storage types which can be migrated but I can find it hard to use it. So I want to share my experience in order to avoid various issues that arise while using it.</p><p>DMS can also support CDC(Change Data Capture) to move the changed data into target endpoints continuously but I can’t handle it in this article.</p><h3>3 migration components</h3><p>AWS DMS performs database migration using three components:</p><ul><li>Replication Instance</li><li>Endpoints(Source &amp; Target)</li><li>Migration Task</li></ul><p>The 3 components will be described later one by one.</p><h3>Replication instances</h3><p>This seems to be a kind of EC2 instance but you can create it in DMS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TP0oekoShkhwXlMuQZCNhA.png" /><figcaption>Replication instances</figcaption></figure><p><strong>You should create a replication instance first</strong> to perform any database migration and this instance will unload data from source endpoint and then load data to target endpoint. All database migration tasks can be done by replication instances. you need to consider the folllowing parmaters when you create your replication instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*HW15MuM-SxWLyWtGcYLg_Q.png" /><figcaption>The example of DMS Replication creation</figcaption></figure><ul><li><strong>Instance class</strong> &amp; <strong>Allocated Storage</strong> will affect your payment later on.</li><li><strong>VPC</strong> should be chosen to enable communication with the source and target endpoints</li><li><strong>Multi AZ </strong>can be chosen for high availability considerations.</li></ul><h3>Endpoints</h3><p>You can define two endpoints as source and target after create replication instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUynbkwjB9GmNjZ4CyDjzQ.png" /><figcaption>Endpoint examples</figcaption></figure><h4><strong>Source Endpoint (RDS)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*ibDGzXJkySFUdqf_nNGIBg.png" /><figcaption>Source endpoint type of RDS</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*2jVwmtD1uzeShnZEJS5jNA.png" /><figcaption>Sample endpoint configuration of RDS</figcaption></figure><ul><li><strong>RDS instance</strong> specifies one of the working RDS instances.</li><li>Database Connection information like server name, port, user, passwork and so on. You can check this information in your RDS instance console.</li><li>You can use AWS Secrets Manager instead of specfiying connection information directly.</li></ul><p>You can check the connectivty of the endpoints on <strong>Test endpoint connection </strong>like this<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*RwbzMme9dP3o_x9Pu5Csew.png" /><figcaption>Test endpoint connection</figcaption></figure><h4><strong>Target Endpoint (Redshift)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*KKZwHrpLwQpFnEuSt_reyg.png" /><figcaption>Target endpoint</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*XVvguzhxKtI-1yn5tOQdIg.png" /><figcaption>Sample endpoint configuration of Redshift</figcaption></figure><ul><li>Server name can be found in the red box of Redshift console like this:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*q-OQ61jBH5C60GMvQ8UJ-Q.png" /><figcaption>Redshift server name(endpoint)</figcaption></figure><ul><li>You should create the specified database first before running migration. If not, you can find the error like ‘the database doesn’t exist in the redshift instance’.</li></ul><h3>Database Migration Tasks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*NzsGCNI-6bAfyFQXXLbzLA.png" /><figcaption>Create task</figcaption></figure><p>You can create your migration task by clicking ‘Create task’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*Akl0xGlUTIk79OEBUAreKQ.png" /><figcaption>The example of migration task configuration</figcaption></figure><ul><li>You can specifiy the replication instance and endpoints(source &amp; target) you created before.</li><li>In migration type, you can choose one among ‘Migrate exsiting data’, ‘Migrate exsiting data and replicate ongoing changes’ and ‘Replicate data chagnes only’. ‘Migrate exsiting data’ means the current data is loaded fully and ‘Replicate ongoing changes’ means CDC(Change Data Capture).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*uzKFf3r5mf5kEE3A_miH8w.png" /><figcaption>Database migration task setting</figcaption></figure><p>You can configure some paramters in task setting if it needed. You can refer the following document for setting parameters.</p><p><a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TaskSettings.html">Specifying task settings for AWS Database Migration Service tasks</a></p><p>I didn’t touch anything here in my case for the purpose of test and you finally are done to create task. The task is automatically started after created as default option. You just wait for process to complete after that. If migration porcess succeeds, you can see ‘Load complete’ with green in Status. Congraturations!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*8x5IkI27yhW7YKPu6N5lYw.png" /><figcaption>Database migration task with ‘Load complete’</figcaption></figure><h3>Workarounds</h3><h4>RDS password issue with special characters(%+;)</h4><p>My operation RDS has a password with ‘%’ and when I tried to create endpoint of that RDS, I met the issue like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGknqyOjm0S3JcXUiZx5dA.png" /><figcaption>RDS password error</figcaption></figure><p>The most simple solution is changing the password, but it’s not my proper option in that time. In some user manuals, it was said that using curly braces could solve it but it didn’t work for me. So, I decided to use another option t to use AWS Secrete Manager.</p><p>You can specify the connection information in Secret Manager and can use its ARN(Amazon Resource Name). Please refere to the following pictures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYebUwOgtKkbEcGLRRJsuQ.png" /><figcaption>Sample secret in AWS Secret</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pg9GJhlzOOzMsNbdujiS9w.png" /><figcaption>RDS migration endpoint confiuration using AWS Secrets Manager</figcaption></figure><h4>Not authorized to get credentials of role dms-access-for-endpoint</h4><p>You can see the error like this during migration to redshift target endpoint.</p><pre>2022–06–16T04:11:16 [TARGET_LOAD ]E: RetCode: SQL_ERROR SqlState: XX000 NativeError: 30 Message: [Amazon][Amazon Redshift] (30) Error occurred while trying to execute a query: [SQLState XX000] <strong>ERROR: Not authorized to get credentials of role arn:aws:iam::&lt;<em>account_id</em>&gt;:role/dms-access-for-endpoint</strong> DETAIL: — — — — — — — — — — — — — — — — — — — — — — — — <strong>error: Not authorized to get credentials of role arn:aws:iam::xxxxxxxxxxxx:role/dms-access-for-endpoint</strong> code: 30000 context: query: 2198 location: xen_aws_credentials_mgr.cpp:403 process: padbmaster [pid=26069] — — — — — [1022502] (ar_odbc_stmt.c:4828)</pre><p>You need to understand the process from RDS to Redshift. DMS doesn’t move RDS data to Redshift directly and use temporary S3 bucket. So you must create the role named dms-access-for-endpoint to access this additional resources. You should create the role first if it doesn’t exist. I know that the rolo creates automatically when migration is done on console only. You should attach a policy and change assume role like these.</p><ul><li>Assume role</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cb8cbae442e5e8004672b5d584be594/href">https://medium.com/media/6cb8cbae442e5e8004672b5d584be594/href</a></iframe><ul><li>2 Policies</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c648685b45d046519e478c726b4dd291/href">https://medium.com/media/c648685b45d046519e478c726b4dd291/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cf2dade476eacb7cdcb5ab44de14f9c/href">https://medium.com/media/6cf2dade476eacb7cdcb5ab44de14f9c/href</a></iframe><p>Please refer to thedocument to read more about it</p><p><a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Security.html#CHAP_Security.APIRole">Security in AWS Database Migration Service</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36bb155d2925" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/how-to-migrate-rds-to-redshift-using-aws-database-migration-service-36bb155d2925">How to migrate RDS to Redshift using AWS Database Migration Service</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[데이터 웨어하우스 서비스 — AWS Redshift]]></title>
            <link>https://medium.com/hatiolab/%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%9B%A8%EC%96%B4%ED%95%98%EC%9A%B0%EC%8A%A4-%EC%84%9C%EB%B9%84%EC%8A%A4-aws-redshift-195802d4cf60?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/195802d4cf60</guid>
            <category><![CDATA[aws-redshift]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Sun, 12 Jun 2022 05:52:34 GMT</pubDate>
            <atom:updated>2022-06-12T05:56:09.657Z</atom:updated>
            <content:encoded><![CDATA[<h3>데이터 웨어하우스 그리고 AWS Redshift</h3><h3>데이터 웨어하우스?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*sxhJYIlPdLUU8s_k.jpg" /><figcaption>출처: <a href="https://datachannel.co/blogs/best-applications-of-data-warehousing/">https://datachannel.co/blogs/best-applications-of-data-warehousing/</a></figcaption></figure><p>데이터 웨어하우스(Data Warehousr, DW)에 대한 정의를 찾아보면 다음과 같습니다.</p><blockquote>데이터 웨어하우스(data warehouse)란 사용자의 의사 결정에 도움을 주기 위하여, 기간시스템의 데이터베이스에 축적된 데이터를 공통의 형식으로 변환해서 관리하는 데이터베이스를 말한다. 줄여서 DW로도 불린다.</blockquote><p>글의 내용만 보면 그럴 듯하지만 저처럼 직접 보지 않고 경험해 보지 않으면 와닿지 않는 상상력 부족한 사람들은 한 가지 의문을 가지게 됩니다.</p><blockquote>그냥 데이터베이스에서 쌓여있는 데이터를 그냥 검색하면 되지 왜 굳이 데이터 웨어하우스가 필요한걸까?</blockquote><p>데이터가 방대하면 시간이 걸리고 부하가 많이 생기기 때문이겠지 정도의 예상은 저도 해보겠지만, 명확한 답을 찾아봐야겠습니다.</p><p><a href="https://www.herzing.edu/blog/what-data-warehousing-and-why-it-important">What is Data Warehousing and Why is it Important?</a></p><ul><li>데이터 웨어하우스는 기존의 데이터베이스가 가지고 있는 데이터 외의 다른 데이터를 저장합니다. 특히, 데이터의 히스토리 정보를 지속적으로 저장하는 것에 의해서 데이터의 추이 분석 등을 가능하게 합니다.</li><li>데이터를 다른 관점에서 바라볼 수 있도록 분류한다고 합니다. 이것은 기존의 OLTP 기반에서 OLAP 기반의 데이터 처리를 말하는 것으로 보입니다.</li><li>OLAP 기반의 데이터를 준비하기 위해서 필연적으로 기존 데이터베이스의 내용을 그대로 저장하지 않고 데이터의 가공을 통해 새로운 형태로 데이터의 저장이 필요할 것으로 보입니다.</li></ul><p>데이터웨어하우스의 목적은 BI(Business Intelligence)도구로서의 가장 큰 목적을 가지고 있으며 다음과 같은 요소들을 도입한 회사에게 제공합니다.</p><ul><li>다양한 데이터를 표준화된 데이터의 형태로 단일화하여 저장함으로서 데이터를 공유하고 분석함에 있어 필요한 전처리 작업 등을 최소화 할 수 있습니다.</li><li>복잡하고 다양한 데이터를 접근하기 위한 방법을 데이터 웨어하우스로 단일화함으로서 회사의 의사 결정을 빠르고 효율적으로 할 수 있도록 합니다.</li><li>회사의 의사 결정은 다양한 비지니스적 요소들을 데이터 웨어하우스에 지속적으로 저장되는 데이터를 통해서 성공 여부를 판가름할 수 있습니다.</li></ul><p>데이터웨어하우스는 간단하게 정리하면 다음과 같이 요약이 가능하겠네요.</p><ul><li>기존 데이터베이스의 데이터는 가공되어야 합니다. 회사 내 축적된 다양한 데이터를 기존처럼 Table들의 join을 통해서 데이터를 얻어내기에는 성능적인 측면이나 방법론적인 측면에서 부합되어 보입니다.</li><li>예를 들면, 식품 공장에서 제품 A의 생산량을 다양한 인자(월, 재료, 날씨, 계절 등등)에 따른 영향성을 분석한다고 하면, 기존 데이터베이스에서도 가능은 해 보이지만 많은 전처리 작업이 예상됩니다. 우선 각각의 Join해야할 테이블의 개수가 10개라고 해도 테이블 간의 조합 개수가 적지 않지만 이렇게 개별적으로 조합된 데이터 내에서 영향성 있는 결론을 만들어 내는 것은 쉽지 않아 보입니다.</li><li>BI 도구로서 큰 목적을 가지고 있으며, 회사가 가지고 있는 다양한 자산을 하나의 데이터 플래폼으로 통일해서 회사 구성원들이 하나의 소스를 가지고 처리를 가능하도록 합니다.</li><li>현재는 데이터웨어하우스에서 처리하기 힘든 대규모 기업의 데이터 관련 요구 사항을 충족하기 위한 데이터레이크, 데이터마트와 같은 개념이 있습니다. 데이터마트는 기존 데이터웨어하우스가 엔드 유저들에 요구되는 다양한 워크로드 부하와 동시성 처리를 모두 만족시키지 못했기 때문에, 데이터 레이크는 빅데이터를 연속적으로 저장하고 처리(속도, 크기, 개수적인 측면)하지 못했기 때문에 탄생했습니다.</li><li>데이터레이크와 데이터마트에 대해서 다른 시간에 다시 내용을 공부해보고 공유하겠습니다. 저희처럼 데이터의 양이 한정되어 있는 경우에는 조금 먼 이야기처럼 들리기도 합니다.</li></ul><h3>AWS Redshift?</h3><p>Things-Factory 플래폼을 통해서 서비스되고 있는 <a href="https://operatochef.com/">OperatoChef</a>와 같은 브랜드들은 현재 AWS에서 서비스하고 있기 때문에 자연스럽게 AWS에서 제공하는 데이터웨어하우스 서비스를 찾아보게 되었으며, 대표적인 서비스로 AWS Redshift가 있습니다.</p><p>AWS Redshift는 PostgresSQL을 기반으로 구현되었으며, 따라서 표준 SQL을 이용한 데이터 처리를 지원하고, BI 도구로 분석할 수 있습니다. 칼럼 기반으로 압축하여 데이터를 저장하고 있어서 데이터의 빠른 처리를 지원합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/0*OfKokhWfh8k7uvzw.png" /><figcaption>출처: <a href="https://docs.aws.amazon.com/ko_kr/redshift/latest/dg/c_high_level_system_architecture.html">https://docs.aws.amazon.com/ko_kr/redshift/latest/dg/c_high_level_system_architecture.html</a></figcaption></figure><p>AWS Redshift의 특징을 살펴보면 클라이언트와 통신을 비롯한 모든 통신을 관리하고 실행 계획을 생성해서 데이터를 구간 별로 컴퓨트 노드(Compute Node)에 분산하는 리더 노드(Leader Node)와 리더 노드에 의해서 분산된 컴파일 코드를 실행하고 최종 집계를 리더 노드에 보내는 컴퓨트 노드로 구성됩니다. 그리고, 리더 노드와 컴퓨트 노드는 고속 네트워크 망으로 구성되어 있습니다. 앞에서 언급한 것처럼, AWS Redshift는 PostgresSQL을 기반의 관계형 데이터베이스 관리 시스템이므로 데이터 삽입 및 삭제와 같은 OLTP 기능을 포함하여 일반적인 관계형 데이터베이스와 동일한 기능을 제공함으로서 일반적인 데이터베이스 어플리케이션과 호환성을 유지할 수 있습니다. 하지만, Amazon Redshift는 매우 큰 데이터 집합의 고성능 분석 및 보고를 위해 최적화 되어 있으며 이러한 성능을 확보하기 위해서 다음과 같은 기능을 내재하고 있습니다.</p><h4>대용량 병렬 처리</h4><p>앞에서 언급한 것처럼 다수의 컴퓨트 노드가 리더 노드의 실행 계획 생성에 따라 데이터를 병렬로 처리할 수 있습니다.</p><h4>열(Column) 기반 데이터 스토리지</h4><p>데이터베이스 테이블을 위한 열 기반 스토리지는 전체 디스크 I/O 요건을 크게 줄여주며 분석 쿼리 성능을 최적화하는 데 중요한 요인입니다. 데이터베이스 테이블 정보를 열 기반 방식으로 저장하기 때문에 디스크 I/O 요청 수가 줄어들 뿐만 아니라 디스크에서 로드해야 하는 데이터 크기가 감소합니다. 적은 데이터를 메모리에 로드하면 Amazon Redshift는 쿼리를 실행할 때 더 많은 메모리 내 처리를 수행할 수 있습니다.</p><h4>데이터 압축</h4><p>스토리지 요건을 줄여 디스크 I/O를 감소시킴으로써 쿼리 성능이 향상되는 효과가 있습니다. 쿼리를 실행하면 압축된 데이터를 메모리로 읽어온 후 쿼리 실행 도중 압축이 해제됩니다. 적은 데이터를 메모리에 로드하면 Amazon Redshift는 더 많은 메모리를 할당하여 데이터를 분석할 수 있습니다.</p><h4>쿼리 옵티마이저</h4><p>Amazon Redshift 쿼리 옵티마이저는 종종 다중 테이블 조인, 하위 쿼리 및 집계를 포함하는 복잡한 분석 쿼리를 처리하기위한 중요한 향상 및 확장을 구현합니다.</p><h4>결과 캐싱</h4><p>쿼리 실행 시간을 줄이고 시스템 성능을 향상시키기 위해 Amazon Redshift는 특정 형식의 쿼리 결과를 리더 노드의 메모리에 캐시합니다. 사용자가 쿼리를 제출하면 Amazon Redshift는 결과 캐시에서 쿼리 결과의 유효한 캐시 된 복사본을 확인합니다. 결과 캐시에서 일치 항목이 발견되면 Amazon Redshift는 캐시된 결과를 사용하고 쿼리를 실행하지 않습니다.</p><h4>컴파일 코드</h4><p>리더 노드는 완전히 최적화된 컴파일 코드를 모든 클러스터 노드로 분산시킵니다. 쿼리를 컴파일하면 인터프리터와 관련된 오버헤드를 제거함으로써 특히 복합 쿼리에서 실행 속도가 빨라집니다.</p><h3>AWS Redshift 데이터 로딩</h3><p>AWS Redshift는 다음과 같은 데이터를 로드하기 위한 방법을 제공합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rg8GzQDDw76JRV1BRlx5Ng.png" /></figure><p>주로, 분석 데이터 저장에 많이 사용되는 S3와 NonSQL 기반의 DynamoDB를 소스로 간단하게 데이터를 로드할 수 있으며, AWS EMR에서도 바로 데이터 로드가 가능합니다. S3에서 Redshift로 데이터를 로딩하는 부분은 다음 블로그를 참조하시면 됩니다.</p><p><a href="https://www.zuar.com/blog/load-amazon-s3-data-to-redshift/">How to Load Data From an Amazon S3 Bucket Into Amazon Redshift | Zuar</a></p><h3>vs. AWS EMR</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/0*HMdayutZsyytjvhs.png" /></figure><p>대용량 데이터 처리, 분석등을 검색하다보면 AWS 서비스 중에서 AWS Redshift와 함께 비교되는 서비스가 AWS EMR 입니다. EMR은 Elastic MapReduce의 약자로서 Apache의 MapReduce 서비스가 떠오릅니다. EMR은 하둡 프레임워크로서 HDFS를 이용한 데이터 저장 및, MapReduce 작업을 통한 대용량 데이터 처리 작업을 수행할 수 있습니다. AWS Redshift는 BI의 방점을 찍고 주로 대용량 데이터의 분석을 타겟으로 한다고 할 수 있고, AWS EMR은 하둡, Presto, Spark 등의 분산된 처리 프레임워크를 효율적으로 사용하기 위한 서비스로서 EMR은 데이터의 분석과 처리 측면에 핵심 기능을 가지고 있다고 할 수 있습니다.</p><h3>vs. GCP BigQuery</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*lo_wYtMhvD0JDCkW.png" /></figure><p>데이터웨어하우스 분야에서 AWS Redshift의 진정한 비교 대상은 GCP BigQuery입니다. GCP BigQuery의 가장 큰 장점은 테이블 컬럼 제한이 10,000개(AWS Redshift이 경우 1600개)와 자체적으로 스트리밍 데이터 입력(AWS Redshift의 경우 AWS Kinesis Firehose로 가능)이 가능하다는 것입니다. 간단하게 정리된 두 서비스와의 차이점은 다음과 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30wimnoZ2rnCG8B02v-KXg.png" /><figcaption>출처: <a href="https://www.stitchdata.com/resources/redshift-vs-bigquery">https://www.stitchdata.com/resources/redshift-vs-bigquery</a></figcaption></figure><p>특히 가격적인 측면에서 두 서비스는 전혀 다른 정책을 사용하고 있는데, BigQuery가 데이터 크기가 커지면 커질 수록 유리한 구조를 가지고 있어 BigQuery 서비스에 대한 고려도 필요할 것으로 보입니다. 현재까지는 저희 대부분의 서비스가 AWS에 종속되어 있어서 이 부분이 용이할 지도 검토가 필요할 것으로 보입니다.</p><h3>정리하며</h3><p><a href="https://medium.com/hatiolab/things-factory-%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC-885741b1ca34">ThingsFactory 프레임워크</a> 기반의 다양한 서비스에서 데이터의 적재, 저장, 분석, 예측과 같은 부가 서비스에 대한 플래폼을 준비하면서 기존의 관계형 데이터베이스 중심의 데이터의 진화가 필요함을 느끼고 있습니다. <a href="https://operatochef.com/">OperaoChef</a>의 경우 다양한 센서 데이터 및 HACCP 기반의 데이터를 기반으로 데이터 분석과 도식화를 위해서, AWS에서 제공하는 S3, Glue Athena, Lambda와 같은 서비스들을 이용해서 서비스를 구성하고 있습니다. 하지만 점차적으로 데이터의 크기와 저장에 대한 규모가 커지면 여러 측면에서 데이터 웨어하우스 플래폼의 도입이 필요할 것으로 생각하고 이에 대한 여러 측면의 준비가 필요할 것으로 보입니다.</p><p>AWS 기반의 클라우스 서비스를 구축하고 있는 현재 시점에서 데이터 웨어하스 구축은 AWS Redshift 도입이 가장 현실적인 방안으로 판단됩니다. AWS Redshift는 2020년 기준으로도 데이터 웨어하우스 서비스 중 가장 많이 도입된 서비스이기도 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v--SlY0rWbPPH8dZ.png" /><figcaption>출처: <a href="https://medium.com/2359media/redshift-vs-bigquery-vs-snowflake-a-comparison-of-the-most-popular-data-warehouse-for-data-driven-cb1c10ac8555">https://medium.com/2359media/redshift-vs-bigquery-vs-snowflake-a-comparison-of-the-most-popular-data-warehouse-for-data-driven-cb1c10ac8555</a></figcaption></figure><p>데이터 분석 측면에서 데이터 웨어하우스 플래폼 도입을 통해서 소비자의 BI에 대한 니즈를 충족시키는 것과 더불어서, 빠른 풀텍스트 검색과 같은 어플리케이션의 요구 사항을 만족하기 위해서 ElasticSearch와 같은 검색 엔진을 다각적으로 도입하는 것을 시도하고 있습니다. 현재 준비 중인 다양한 서비스가 구체화되고 구현되면 다시 소개할 수 있는 시간을 마련하도록 하겠습니다.</p><h3>참고</h3><ul><li><a href="https://hevodata.com/learn/amazon-emr-vs-redshift/">https://hevodata.com/learn/amazon-emr-vs-redshift/</a></li><li><a href="https://www.integrate.io/blog/amazon-redshift-how-aws-redshift-compares-to-other-warehouse-data-solutions/">https://www.integrate.io/blog/amazon-redshift-how-aws-redshift-compares-to-other-warehouse-data-solutions/</a></li><li><a href="https://docs.aws.amazon.com/redshift/latest/dg/c_challenges_achieving_high_performance_queries.html">https://docs.aws.amazon.com/redshift/latest/dg/c_challenges_achieving_high_performance_queries.html</a></li><li><a href="https://118k.tistory.com/638">https://118k.tistory.com/638</a></li><li><a href="https://www.zuar.com/blog/load-amazon-s3-data-to-redshift/">https://www.zuar.com/blog/load-amazon-s3-data-to-redshift/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=195802d4cf60" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%9B%A8%EC%96%B4%ED%95%98%EC%9A%B0%EC%8A%A4-%EC%84%9C%EB%B9%84%EC%8A%A4-aws-redshift-195802d4cf60">데이터 웨어하우스 서비스 — AWS Redshift</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gRPC 기술 검토]]></title>
            <link>https://medium.com/hatiolab/grpc-%EA%B8%B0%EC%88%A0-%EA%B2%80%ED%86%A0-9d91f2175393?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d91f2175393</guid>
            <category><![CDATA[things-factory-framework]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[web-framework]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Sun, 29 May 2022 07:19:11 GMT</pubDate>
            <atom:updated>2022-05-29T15:12:03.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>서비스 간 통신에 대한 고찰</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHp0gzsTmzpLC_QhCAI8wQ.png" /></figure><p><a href="https://medium.com/hatiolab/things-factory-%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC-885741b1ca34">Things-Factory 프레임워크</a> 기반의 다양한 어플리케이션 중에서 로봇 응용 어플리케이션 개발에 특화된 <a href="https://medium.com/hatiolab/aidoop-r-%ED%98%91%EB%8F%99-%EB%A1%9C%EB%B4%87-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EA%B0%9C%EB%B0%9C-%ED%94%8C%EB%9E%98%ED%8F%BC-4dd558b32bf5">AIdoop-R</a> 플래폼은 비전 기반의 로봇 어플리케이션 구축을 위해서 Intel사의 <a href="https://www.intelrealsense.com/">Realsense</a> 카메라와 같은 비전 센서 데이터 처리와 피킹 오브젝트 검출을 <a href="https://www.tensorflow.org/">TensorFlow</a> 활용과 같이 C++나 Python를 기반으로 하는 별도의 서비스 구현이 불가피했습니다. 이와 같은 서비스 구현에 있어 필수적인 부분은 두 서비스 간의 데이터를 교환하기 위한 통로를 생성하는 것이었으며 AIdoop-R 플래폼에서 기본적으로 제공하는 다음 두 개의 프로토콜을 이용해서 서비스 구축을 진행했습니다.</p><ul><li>플래폼에서 제공하는 다양한 데이터를 Query하고 Mutation할 수 있는 GraphQL</li><li>비디오 프레임과 같이 지속적으로 데이터를 수신 및 처리가 필요할 경우 WebSocket</li></ul><p>GraphQL이나 WebSocket은 Things-Factory에서 기본적으로 제공하는 기능으로서 바로 적용할 수 있는 장점을 가지고 있지만, 마이크로서비스로의 확장에 개발 지향성을 가지고 있는 현재의 프레임워크는 다음과 같은 요구사항을 충족하는 새로운 서비스간 통신 경로를 도입해야 합니다.</p><ul><li>서비스가 데이터 송수신 크기가 클 수 있기 때문에 데이터는 최대한 가벼워야 하고 호출 방식도 간단해야 합니다.</li><li>서비스 간의 통신 규약을 정의할 수 있어야 합니다.</li><li>데이터 해킹에 안전하도록 암호화 및 보안 서비스가 필수적으로 수반되어야 합니다.</li><li>서비스가 다양한 언어로 구현될 수 있으며 개별 언어를 기반으로 하는 API를 지원해야 합니다.</li></ul><h4>마이크로서비스 측면에서의 고려 사항</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ddn3GEEv9UIkeNxw.jpg" /><figcaption>출처: <a href="https://www.ciokorea.com/insider/36479">https://www.ciokorea.com/insider/36479</a></figcaption></figure><p>마이크로서비스 아키텍처 기반의 서비스 구축에 있어 고려가 되어야 하는 주요 사항은 네트워크 속도와 서비스 간 통신 규약을 정의하는 일입니다. 기존 모놀리식(Monolithic) 아키텍처에서 모듈 혹은 서비스 간의 통신은 하나의 프로세스에서 발생하지만 마이크로서비스 아키텍처의 경우, 다양한 서비스들이 다른 프로세스, 다른 호스트에서 돌아가고 있기 때문에 서비스 간 네트워크 속도를 줄이는 일은 전체 아키텍처의 성능에 지대한 영향을 줄 수 있습니다. 2017년 기준으로 구글이 1주일동안 띄우는 컨테이너가 20억개에 달한다고 하고, 1초 동안 호출되는 원결 호출의 수가 100억번이라고 합니다. 이러한 호출 수를 미루어보면 몇 밀리세컨드의 네트워크 시간을 줄이는 것이 얼마나 큰 영향을 줄 지 미루어 짐작해 볼 수 있습니다. 그리고, 서비스 간의 통신 규약을 정하는 것도 매우 중요합니다. 서비스 사이 의존성이 낮아지면서 얻은 장점 대신, 각 서비스가 변경되면서 발생할 수 있는 문제들이 발생하고 있습니다. 물론 기존 API 서비스에도 OpenAPI(Swagger) 같은 도구를 사용하거나 잘 구성된 문서를 통해 규약을 맞추는 것이 가능하지만 이 역시 사용자에 입장에서는 학습이 필요합니다.</p><h3>gRPC?</h3><p>MSA 기반 어플리케이션 프레임워크를 구성함에 있어서 위에 나열된 여러 기능들을 충족할 수 있는 대표적인 네트워크 프레임워크인 gRPC에 대해서 알아보고자 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*4HAfmp1Hu0L1cQM1.png" /><figcaption>출처: <a href="https://blog.logrocket.com/how-to-build-a-grpc-server-in-dart/">https://blog.logrocket.com/how-to-build-a-grpc-server-in-dart/</a></figcaption></figure><h4>HTTP/2 기반의 네트워크 프레임워크</h4><p>gRPC는 구글에서 만들고 오픈 소스로 운영 중인 RPC(Remote Procedure Call) 프레임워크입니다. Protocol Buffers를 사용하여 서비스를 쉽게 정의하고 사용할 수 있습니다. HTTP/2를 기반으로 구성되어서 상당히 빠르며, 양방향 스트리밍도 가능합니다. 따라서 Json 기반으로 통신하는 Rest API 보다 더 가볍고, HTTP/2 기반이기 때문에 하나의 채널 커넥션을 맺고 그 커넥션을 통해서 동시에 메시지를 보내고 처리할 수 있습니다. 이런 이유로 전체적인 통신 속도의 향상 또한 크게 기대할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*yHLyew7u00oFbORg.png" /><figcaption>출처: <a href="https://dev.to/techschoolguru/http-2-the-secret-weapon-of-grpc-32dk">https://dev.to/techschoolguru/http-2-the-secret-weapon-of-grpc-32dk</a></figcaption></figure><p>HTTP/2과 기존 HTTP 1.1과의 성능 비교는 다음 URL을 통해서 확인하실 수 있습니다.</p><p><a href="http://www.http2demo.io/">HTTP/2 technology demo</a></p><p>HTTP/2를 기반으로 하면 수명이 긴 실시간 통신 스트림과 관련해서 다양한 조합을 지원합니다.</p><ul><li>단항(스트리밍 없음)</li><li>서버-클라이언트 스트리밍</li><li>클라이언트-서버 스트리밍</li><li>양방향 스트리밍</li></ul><h4>vs. REST API</h4><p>gRPC와 HTTP API 간의 기능 비교는 다음 표를 참고 부탁 드립니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*QXXpphq0lF40hQk9eNBHHA.png" /><figcaption>출처: <a href="https://docs.microsoft.com/ko-kr/aspnet/core/grpc/comparison?view=aspnetcore-6.0">https://docs.microsoft.com/ko-kr/aspnet/core/grpc/comparison?view=aspnetcore-6.0</a></figcaption></figure><ul><li>gRPC 메시지는 효율적인 이진 메시지 형식인 <a href="https://developers.google.com/protocol-buffers/docs/overview">Protobuf</a>를 사용하여 작은 메시지 페이로드를 발생시킴으로서 빠른 직렬화를 가능하게 합니다.</li><li>gPRC 프레임워크는 서비스 기본 클래스, 메시지, 클라언트 생성에 대한 최고 수준의 지원을 제공합니다. gPRC 개발의 핵심 파일은 gRPC 서비스 및 메시지의 계약을 정의하는 <a href="https://developers.google.com/protocol-buffers/docs/proto3">.proto 파일</a>입니다.</li><li>json을 사용하는 기존 HTTP API의 경우 공식적인 사양의 정의는 존재하지않습니다. 하지만 gRPC는 서비스가 따라야 하는 형식에 대한 지침을 제공합니다. gRPC는 이와 같은 <a href="https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md">사양 정의</a>를 통해서 구현에 있어서 불필요한 논쟁을 제거합니다.</li></ul><h4>gRPC의 단점</h4><ul><li>gRPC는 HTTP/2 기능을 많이 사용하며, 브라우저에서 gRPC 클라이언트를 지원하기 위해 웹 요청에 필요한 제어 수준을 제공하지 않습니다. 예를 들어, 브라우저는 호출자가 HTTP/2를 사용하도록 요구하거나 기본 HTTP/2 프레임에 대한 액세스를 제공하지 않습니다. gRPC를 브라우저 앱으로 가져오기 위해서는 <a href="https://grpc.io/docs/platforms/web/basics/">gRPC-Web</a>과 같은 별도의 추가 기술이 필요합니다. 하지만 gRPC-Web의 경우에는 모든 gRPC 기능을 제공하지는 않습니다.</li><li>gRPC 메시지는 기본적으로 Protobuf로 인코딩되기 때문에 네트워크 효율은 증가하지만 이진 형식으로서 사람이 읽을 수 없고, 페이로드 분석을 위해서는 별도의 분석 도구가 필요합니다.</li></ul><h3>gRPC 구현 예제</h3><p>gRPC에 대한 기술적인 내용을 이해하기 위해서 간단하게 예제 코드를 통해서 구현 방법을 이해해 보고자 합니다. 예제 코드는 gRPC 공식 사이트의 예제를 참고했습니다. gRPC는 C#, C++, Go, Java, Node, Python 등의 많이 사용되는 다양한 언어를 지원하고 있습니다.</p><h4>서비스 정의</h4><p>앞에서 언급한 것처럼, gRPC의 특징 중에 여러번 언급된 <a href="https://developers.google.com/protocol-buffers/docs/overview">Protocol Buffers</a> 기반으로 서비스를 정의할 수 있습니다. 서비스 정의는 .proto 파일에서 정의를 하면 다음과 같이 정의가 됩니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92ea96444918789597dd0306c3e033b3/href">https://medium.com/media/92ea96444918789597dd0306c3e033b3/href</a></iframe><ul><li><strong>RouteGuide</strong>라는 서비스를 정의하고 있습니다. <strong>RouteGuide</strong> 서비스 내에는 4개의 <strong>rpc</strong>를 정의하고 있습니다.</li><li>각각의 <strong>rpc</strong> 정의 및 구현에 있어서 데이터 포맷은 <strong>message</strong>라고 하는 키워드를 통해서 <strong>Point</strong>, <strong>Rectangle</strong>과 같은 메시지 이름과 내부 구성을 정의하고 있습니다.</li><li>rpc 정의에 있어서 stream 키워드의 유무에 따라서 4개의 메시지로 분류할 수 있습니다.</li><li><strong>A simple RPC: GetFeature</strong> <strong>rpc</strong>는 가장 간단한 형태의 정의로서 클라어언트가 Point 메시지를 보내면 Feature라는 회신이 올 때까지는 대기합니다.</li><li><strong>A response-streaming RPC: ListFeatures rpc</strong>는 서버가 stream 형식으로 메시지를 회신하도록 구성됩니다. 이 경우에는 클라이언트가 Retangle 메시지를 보내면 Feature 메시지를 서버가 유효한 메시지가 없을 때까지 계속 보냅니다.</li><li><strong>A request-streaming RPC</strong>: <strong>RecordRoute rpc</strong>는 한 개 이상의 메시지를 클라이언트가 메시지를 보냅니다. 서버는 클라이언트의 메시지를 모두 읽고 클라이언트의 메시지가 전송이 종료되면 응답 메시지를 보냅니다.</li><li><strong>A bindirectional-streaming RPC</strong>: RouteChat rpc는 앞의 경우와는 다르게 클라이언트와 서버 모두 독립적으로 메시지를 처리할 수 있습니다. 그래서 서버와 클라이언트는 서버 혹은 클라이언트의 메시지 완료 여부를 확인하지 않고도 메시지를 전송할 수 있습니다. 예를 들면, 서버는 클라이언트의 모든 메시지가 도착할 때까지 기다렸다가 응답 메시지들을 보낼 수도 있고, 클라이언트의 개별 메시지를 받을 때마다 응답 메시지를 전송할 수도 있습니다.</li></ul><h4>코드 생성</h4><p>앞에서 생성한 서비스 파일들은 어떻게 활용되는 것일까요? 많은 분들이 친숙한 Python을 통해서 알아보겠습니다. 이렇게 정의된 .proto 파일은 Python의 경우 grpcio-tools라는 pip 모듈을 통해서 다음과 같이 생성 가능합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*WSGRTj3jOqQgbNxawODQ1Q.png" /></figure><p>생성된 두 개의 파일은 다음과 같습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d425dbaf45368a9333db29a9ad1741f/href">https://medium.com/media/2d425dbaf45368a9333db29a9ad1741f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eca4700a621f0c4a7addc2290ac8592a/href">https://medium.com/media/eca4700a621f0c4a7addc2290ac8592a/href</a></iframe><p>생성된 파일은 차후 서버와 클라이언트 코드 구현 시에 .proto 파일에 저장된 메시지 정의와 서비스의 Stub 코드를 제공합니다.</p><h4>서버 구현</h4><p>앞에서 소개된 .proto 파일에 의해서 생성된 코드를 참조해서 서버를 손쉽게 구현할 수 있습니다.</p><p>Server에서 구현이 필요한 각 rpc는 route_guide_pb2_grpc에 정의된 Servicer 클래스를 부모클래스로 받아서 구현합니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6e9f6301663773985c7da463e42e9cc/href">https://medium.com/media/b6e9f6301663773985c7da463e42e9cc/href</a></iframe><ul><li>grpc.server 함수를 통해서 간단하게 서버 실행이 가능합니다.</li><li>rpc 구현에 필요한 메시지 타입은 생성된 route_guide_pb2 내의 정의를 참조합니다.</li><li>개별 rpc는 route_guide_pb2_grpc.RouteGuideServicer 클래스에 정의된 함수를 오버라이드해서 구현합니다.</li></ul><h4>클라이언트 구현</h4><p>클라이언트 구현은 보다 간단합니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ebcd1828f265206315ea66872b4da99/href">https://medium.com/media/2ebcd1828f265206315ea66872b4da99/href</a></iframe><ul><li>클라이언트는 route_guide_pb2_grpc에서 제공하는 stub를 사용해서 구현합니다.</li><li>stub에 정의된 <strong>RouteChat rpc</strong>를 호출하기 위해서 <strong><em>guide_route_chat</em></strong> 함수에서 스트림 타입의 메시지를 생성하고 이를 호출하고 응답 메시지 스트림을 받아서 메시지 별로 출력하는 예를 확인하실 수 있습니다.</li></ul><blockquote>stub는 RPC에서 주로 언급되는 핵심 개념입니다. 클라이언트와 서버가 서로 다른 주소 공간을 사용하기 때문에 함수 호출에 사용되는 파라미터를 바로 사용하지 않고 변환하는 작업이 필요합니다. 클라이언트와 서버에서 역할이 다르기 때문에 클라이언트에서 함수 호출을 위한 변환을 마샬링(Marshalling)이라고 하고 서버에서 클라이언트가 변환한 매개변수를 다시 역변환하는 작업을 언마샬링(Unmarshalling)이라고 합니다.</blockquote><h3>정리하며..</h3><p>구글에서 개발된 네트워크 프레임워크인 gRPC는 많은 장점을 가지고 있지만 그 중에서도 다음과 같은 장점들이 MSA에 적극적으로 사용될 것으로 예상됩니다.</p><ul><li>개발자의 입장에서는 메시지의 구성이라는 비지니스 로직 측면의 핵심에 집중할 수 있습니다. 단지 서비스에서 제공하는 기능에 대한 종류(rpc)와 입출력 메시지(message)만 정의하면 gRPC는 메시지 구현을 제외한 다양한 형태의 고민을 덜어 줍니다.</li><li>Protocol Buffer를 이용한 고성능의 직렬화 및 역직렬화를 채택함으로서 네트워크의 성능에 있어서 가장 영향을 주는 부하와 속도에 있어서 주요한 이점을 가지고 있습니다.</li><li>거의 현재 가장 많이 사용되는 프로그래밍 언어들을 지원하고 있고 많은 다양항 예제들을 제공하고 있어 구현이 매우 용이하고 호환성 확보 측면에서도 거의 문제가 없을 것으로 보입니다.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d91f2175393" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/grpc-%EA%B8%B0%EC%88%A0-%EA%B2%80%ED%86%A0-9d91f2175393">gRPC 기술 검토</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[데이터옵스(DataOps) 기술 검토]]></title>
            <link>https://medium.com/hatiolab/%EB%8D%B0%EC%9D%B4%ED%84%B0%EC%98%B5%EC%8A%A4-dataops-%EA%B8%B0%EC%88%A0-%EA%B2%80%ED%86%A0-7d4862650957?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d4862650957</guid>
            <category><![CDATA[dataops]]></category>
            <category><![CDATA[web-framework]]></category>
            <category><![CDATA[dataops-automation]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Mon, 23 May 2022 06:32:36 GMT</pubDate>
            <atom:updated>2022-05-25T01:35:14.986Z</atom:updated>
            <content:encoded><![CDATA[<h3>데이터옵스(DataOps)?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*qaBfxhKkfnxq5i8h" /><figcaption>출처: <a href="https://blog.naver.com/PostView.nhn?blogId=smartnari&amp;logNo=222110346637&amp;from=search&amp;redirect=Log&amp;widgetTypeCall=true&amp;directAccess=false">https://blog.naver.com/PostView.nhn?blogId=smartnari&amp;logNo=222110346637&amp;from=search&amp;redirect=Log&amp;widgetTypeCall=true&amp;directAccess=false</a></figcaption></figure><p>데브옵스(DevOps)에 데이터와 관련된 기능이 추가된 것이겠지하고 잠정적으로 정의를 내리고 바쁘다는 핑계를 대면서 애써 모른척하고 있었지만 현재 진행 중인 여러 프레임워크 기반의 서비스에서 데이터 가공과 예측에 대한 수요를 만족하기 위한 플래폼 및 서비스 구현이 필요하면서 이와 관련된 다양한 데이터옵스 솔루션들을 검토하고 있습니다. 우선 기능 구현에 급급하기 보다는 데이터옵스에 대한 정의와 관련 서비스들, 그리고 다른 업체들의 사례들을 살펴보면서 제공하고자 하는 서비스의 목적에 따라서 설계의 다양성을 데이터옵스(DataOps) 관련한 정의와 도입 방법들을 확인할 필요가 생겼습니다. 데이터옵스라는 용어에 대해서는 다양한 정의를 찾아볼 수 있는데, 처음 이 용어를 사용한 앤디 팔머는 다음과 같이 정의했습니다.</p><blockquote>DataOps는 데이터 엔지니어링 조직이 사용자에게 더 빠르고 광범위하게 준비된 데이터를 제공할 수 있도록 해주는 툴과 문화 프레임워크로 데이터 엔지니어링, 데이터 통합, 데이터 품질, 데이터 보안의 교차 지점이다. DataOps는 기본적으로 팀에 협업 기술을 도입해 데이터 엔지니어링 범위 내의 모든 역할과 책임을 통합시키는 포괄적 용어다. 데이터옵스의 미션은 다양한 통합과 배치 업무에 대한 테스팅 부담을 공동 할당하는 방식으로 데이터를 제공하는 것이다.</blockquote><p>또한, IBM에서 다음과 같은 정의도 찾을 수 있었습니다.</p><blockquote>적합한 데이터를 적시에 올바른 장소로 가져올 수 있는 프로세스를 자동화 함으로써 데이터를 활용하는 역량을 최대한 발휘하도록 하는 전략적인 실행 방법 및 관리 프로세스</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*zs42pEnRXpd9aSfJ.jpg" /><figcaption>출처: <a href="https://www.eweek.com/development/best-practices-for-data-management-using-dataops/">https://www.eweek.com/development/best-practices-for-data-management-using-dataops/</a></figcaption></figure><p>데이터옵스는 데이터의 수집, 저장, 보호라는 기존에 중시되는 개별 기술에 대한 요구가 아니라 개별 기술들을 아우르는 운영 측면에 방점을 찍고 있는 것으로 보입니다. 데브옵스가 소프트웨어 개발 전반에 있어서 배포가 최종 타겟인 자동화된 파이프라인을 구축하는 것이 목표라면 데이터옵스는 다음과 같은 목표를 가지고 있습니다.</p><ul><li>데이터 소비자를 위해 신속하게 사용할 수 있는 고품질 데이터를 소비자가 다른 장벽없이도 접근이 가능하도록 해야 합니다.</li><li>데이터 거버넌스 및통합을 자동화하고 규제 문제를 보호하면서 지속적인 데이터 접근이 가능하도록 합니다.</li><li>지속적으로 데이터 파이프라인을 모니터링하고 최적화하여 모든 데이터 소비자의 지속적인 학습을 위한 데이터 환경이 제공 가능하도록 합니다.</li></ul><h4>데브옵스(DevOps), 데이터옵스(DataOps), 엠엘옵스(MLOps)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBEB9Wdb9EuMqrM7Q3sDhg.png" /></figure><p>데이터옵스는 데브옵스와는 달리 소프트웨어 개발 자동화를 포함하면서도 데이터 수집 및 분석과 관련한 파이프라인을 구성합니다. 데이터옵스를 통해서 구성된 데이터는 이후 엠엘옵스 구성에 있어 모델 훈련을 위한 양질의 데이터를 제공하는 기반을 마련합니다.</p><h4>데이터옵스 아키텍처</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*8OVz3aFbNarFrKOk.png" /><figcaption>출처: <a href="https://medium.com/data-ops/what-is-dataops-ten-most-common-questions-ffc09c09c921">https://medium.com/data-ops/what-is-dataops-ten-most-common-questions-ffc09c09c921</a></figcaption></figure><p>데이터옵스는 데이터 소스에서 데이터를 수집, 가공, 분석 과정을 통해서 데이터 사용자에게 지속적으로 양질의 데이터를 공급하기 위해서 기능 별 적합한 솔루션을 기반으로 제공하는 플래폼입니다. 이렇게 구성된 플래폼은 Dev 단계, Test 단계를 거쳐서 최종 Production 단계이 이르기까지 플래폼의 과정이 반복적으로 수행되면서 목적에 부합되는 양질의 데이터를 생성하는 파이프라인이 구축됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*kvTSUQZgk7wLg6uyENSZeA.png" /><figcaption>출처: http://www.2e.co.kr/news/arcticleView.html?idxno-210844</figcaption></figure><p>데이터옵스 아키텍처는 다음과 같은 솔루션 구성 요소들로 구성될 수 있습니다.</p><ul><li>Storage/Revision Control: Git이나 Docker Hub 등을 이용한 데이터 버전 관리</li><li>History and MetaData: 데이터옵스 플래폼의 시스템 및 로그 등을 관리하기 위한 데이터베이스</li><li>Environment Secret: 플래폼 데이터의 데이터와 리소스 접근을 관리하기 위한 권한 관리(Vault(<a href="https://www.vaultproject.io/">https://www.vaultproject.io</a>))</li><li>Metrics and Reports: 데이터 분석에 필요한 다양한 메트릭과 레포트 제공( Tableau(<a href="https://www.tableau.com/ko-kr">https://www.tableau.com/ko-kr</a>))</li><li>Automated Development: DevOps에서 동일하게 요구되는 Dev 환경에서 최종 Product 환경으로의 데이터 및 코드가 자동화되어 이동할 수 있는 환경 제공(jenkins (<a href="https://www.jenkins.io/">https://www.jenkins.io/</a>), CircleCI (<a href="https://circleci.com/">https://circleci.com/</a>))</li><li>Environment Creation and Management: Dev, Test, Product의 개별 환경에 대해서 각각 Data 수집, 가공, 분석을 수행하는 프로세스를 구성하고 관리</li><li>Orchestration, Testing , Monitoring: 개별 환경 단위로 구성된 데이터 파이프라인을 구성하는 개별 솔루션과 툴들이 유기적으로 구성되어 실행되고 있는 지를 지속적으로 모니터링.</li></ul><h3>데이터옵스 적용 사례</h3><h4>Superb-컴퓨터 비전 데이터를 위한 데이터옵스</h4><p><a href="https://www.superb-ai.com/ko-blog/dataops-part3">컴퓨터 비전 프로젝트를 위한 DataOps 팀빌딩 하기 Part3</a></p><p>Superb는 컴퓨터 비전의 모델 생성에 필요한 비디오 및 이미지 데이터에 데이터옵스 팀 구성에 있어서 필요한 사항들을 잘 정리하고 있습니다. 특히 영상에 대한 인덱싱은 많은 수작업이 필요한 작업인데 이러한 작업들을 최대한 자동화하면서도 데이터의 질을 높이는데 초점을 가지고 있습니다.</p><h4>Azure 기반 사례들</h4><p><a href="https://github.com/Azure-Samples/modern-data-warehouse-dataops#end-to-end-samples">GitHub - Azure-Samples/modern-data-warehouse-dataops: DataOps for the Modern Data Warehouse on Microsoft Azure. https://aka.ms/mdw-dataops.</a></p><p>Azure 클라우드 서비스의 경우, 데이터옵스와 관련한 많은 사례들을 소개하고 있습니다. 개발, 검증, 배포에 이르는 환경마다 데이터를 수집, 가공, 정제하는 작업을 수행할 수 있는 사례들을 소개하고 있습니다.</p><ul><li>주차 센서 솔루션</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xr8jck-A30ly6euO" /><figcaption>Synapse 기반 DataOps 플래폼 구성</figcaption></figure><p>주차 센서에 대한 데이터를 수집하고 데이터 분석, 처리하는 위 모델은 Azure Synapse 분석 서비스를 기반으로 구성하고 있습니다. 해당 모델은 Dev, Stage, Production 환경에 대해서 개별적으로 데이터옵스 파이프라인을 구성하도록되어 있습니다. 개별 환경에 파이프라인을 통해서 데이터가 완료되면 다음 단계로 자동으로 처리되도록 구성되어 있는 End-to-End 기반의 데이터옵스 플래폼 구성 예입니다.</p><ul><li>온도 센서 기반 솔루션</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*96KFhP6xZ0rua5vP" /></figure><p>온도 센서 기반 솔루션은 기본적으로 TerraForm에 의해서 프로비저닝 되도록 구성됩니다. 센서 데이터 및 Azure Function의 이벤트를 처리하는 Azure EventHub와 데이터를 가공 및 처리하는 Azure Function으로 구성됩니다. 그 외에 <a href="https://github.com/Azure-Samples/Iot-Telemetry-Simulator/">Azure IoT Device Telemetry Simulator</a>와 <a href="https://azure.microsoft.com/en-au/services/devops/">Azure DevOps</a> 등의 서비스를 통해서 DataOps 플래폼을 구성하고 있습니다.</p><h4>Netflix</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FnMyuCdqzpZc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnMyuCdqzpZc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FnMyuCdqzpZc%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c0c1dba0fdd26696b70c96691577488/href">https://medium.com/media/4c0c1dba0fdd26696b70c96691577488/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*i1l1VKCgA8mAVxXU6DYOpA.png" /><figcaption>출처: <a href="https://www.youtube.com/watch?v=nMyuCdqzpZc">https://www.youtube.com/watch?v=nMyuCdqzpZc</a></figcaption></figure><p>넷플릭스는 주로 사용자의 경험을 이벤트 단위로 데이터를 수집(Kafka, S3, Spark)하고 이를 가공 및 저장(Amazon Redshift, Elasticsearch, Druid), 검색 및 분석(Presto, Spark, R, Python) 그리고, 비주얼라이제이션(Tableau)하는 주요 흐름을 자동화 함으로서 사용자 추천 서비스를 지속적을 강화하고 있습니다.</p><h3>정리하며..</h3><p>데이터옵스(DataOps)와 관련해서 기술 검토한 내용을 정리해 보면 다음과 같습니다.</p><ul><li>기존 데브옵스(DevOps)는 개발, 테스트, 배포의 자동화 파이프라인을 구축하는 것이 주요 목적이라고 하면, 데이터옵스는 데브옵스의 내용에 추가로 데이터를 수집, 가공 및 정제하는 파이프라인을 추가로 구성한다고 볼 수 있습니다.</li><li>데브옵스는 기존 개발과 테스트팀이 주도하고 있다고 하면, 데이터옵스는 데이터 분석팀이 이 과정을 함께 주도하도록 구성됩니다.</li><li>데이터옵스는 하나의 파이프라인에 초점을 맞추기보다는 플래폼 관점으로 바라보아야 합니다. 개발, 테스트, 프로덕션 개별 환경에서의 데이터 관련 파이프라인이 구성되고 자동으로 다음 단계 환경으로 데이터가 전이되는 일련의 과정을 갖추고 있는 플래폼으로서 의미를 가지고 있습니다.</li><li>데이터옵스와 관련해서 자주 사용되는 툴이나 서비스는 다양하게 존재하지만 그것은 용도와 목적에 의해서 항상 변경될 수 있으며 정답이 존재하지는 않는 것 같습니다. Azure, AWS, IBM 등에서 여러 다양한 DataOps와 관련된 서비스와 플래폼들을 제공하고 있습니다.</li><li>대형 플래폼 서비스 외에도 다음과 같은 다양한 솔루션 툴들이 있습니다.(<a href="https://datakitchen.io/">DataKitchen</a>, <a href="https://www.tengu.io/">TENGU</a>, <a href="https://mlflow.org/">MLFlow</a>, <a href="https://streamsets.com/">StreamSets</a>, <a href="https://www.k2view.com/">K2View</a>)</li></ul><p>Things-Factory 프레임워크를 기반으로 OperatoChef나 다양한 물류 서비스에서 활용되고 있는 어플리케이션들은 수요 예측, 오류 검출과 같은 데이터 기반의 서비스를 요구하고 있습니다.저희는 이와 같은 요구 사항을 만족하기 위한 데이터옵스 플래폼 구축을 진행하고 있으며, 앞으로 플래폼 구축이 완료되면 구축 경험과 생각해볼 내용들을 주제로 내용을 공유하도록 하겠습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d4862650957" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/%EB%8D%B0%EC%9D%B4%ED%84%B0%EC%98%B5%EC%8A%A4-dataops-%EA%B8%B0%EC%88%A0-%EA%B2%80%ED%86%A0-7d4862650957">데이터옵스(DataOps) 기술 검토</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS IOT 서비스 검토]]></title>
            <link>https://medium.com/hatiolab/aws-iot-%EC%84%9C%EB%B9%84%EC%8A%A4-%EA%B2%80%ED%86%A0-e40484a88d5d?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/e40484a88d5d</guid>
            <category><![CDATA[operato-chef]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[iot-platform]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Sun, 15 May 2022 12:17:01 GMT</pubDate>
            <atom:updated>2022-05-15T22:52:26.462Z</atom:updated>
            <content:encoded><![CDATA[<h3>Operato Chef</h3><p><a href="https://operatochef.com/index.html">F&amp;B management platform</a></p><p>Things-Factory 프레임워크를 기반으로 현재 서비스를 준비 중인 Operato Chef(<a href="https://operatochef.com/">https://operatochef.com</a>)는 하티오랩에서 야심차게 준비하고 있는 식음료 제조 및 관리에 특화된 자동화 플래폼입니다. 이와 같은 식음료 서비스에서 요구되는 기능 중에서도 온도, 습도 센서와 같은 장치들을 관리하고 개별 센서들의 수신 데이터를 로깅하고 데이터 유효성을 판단하는 기능이 식음료 생산 자동화에 있어 핵심적인 기능을 담당합니다.</p><h3>클라우드 IOT 서비스</h3><p>기존의 장치들을 제어하기 위한 소프트웨어나 서비스들은 주로 온프레미스 기반으로 설치가 되서 해당 네트워크 내의 장치들을 관리하고 수집하고 제어하는 기능을 수행했었습니다. 하지만 주요 서비스들이 클라우드 기반의 Saas나 Pass로 제공되고 있고, 관리가 필요한 IoT 센서들이 기하급수적으로 늘어나면서 장치 및 메시지에 대한 관리 서비스가 IoT 서비스의 핵심으로 자리잡고 있습니다. 또한 클라우드 기반의 서비스가 서비스 내의 네트워크가 아니고 외부의 네트워크를 사용하고 있는 센서와 연결하기 위해서는 보안 관련 이슈가 가장 큰 화두가 되고 있습니다. 이와 같은 주요 문제들을 해결하고 효율적인 관리 수단을 제공하기 위해서 클라우드 플래폼들은 IoT 관련 서비스들을 제공하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r1F_DLVZbaVgs3lD.png" /><figcaption>Source: <a href="https://iot-analytics.com/iot-cloud/">https://iot-analytics.com/iot-cloud/</a></figcaption></figure><p>각 클라우드 플래폼 별 서비스에 대한 비교는 다음 링크에서 잘 정리되어 있습니다.</p><p><a href="https://iot-analytics.com/iot-cloud/">The IoT cloud: Microsoft Azure vs. AWS vs. Google Cloud</a></p><p>개별 플래폼들이 공통적으로 제공하는 기능들은 다음과 같이 요약할 수 있습니다.</p><ul><li>IoT 서비스에 등록된 장치들을 관리합니다.(Azure IoT Hub, AWS IoT Devicemanagememt)</li><li>IoT 센서의 데이터들을 수집하고 관리합니다.(Azure IoT Edge, AWS IoT Core/Analytics)</li><li>별도의 IoT 장치들에 특화된 어플리케이션을 활성화하고 관리할 수 있는 별도의 어플리케이션 서비스가 준비되어 있습니다.(Azure IoT Centeral, AWS IoT FleetWise)</li></ul><h3>AWS IoT</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/0*bjqq7xNgWqDWFGG7.png" /><figcaption>AWS IOT 서비스 개요</figcaption></figure><p>AWS IoT는 Core, Device Management, Device Defender와 같은 주요 제어 서비스를 비롯해서, AWS IoT 연결과 관련된 장치 소프트웨어 FreeRTOS, 데이터 분석 서비스인 Data Anlaytics 등이 제공되고 있습니다. 본 내용에서는 주로 처음 AWS IoT 활성화를 위한 IoT Core와 IoT Device Manangement 서비스에 대해서 알아보고 간단하게 사용 방법을 확인하도록 하려고 합니다.</p><h4>AWS IoT Device Manangement</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*UGSAcyATZXLbLELyzilAIg.png" /><figcaption>Source: <a href="https://www.youtube.com/watch?v=WAp6FHbhYCk">https://www.youtube.com/watch?v=WAp6FHbhYCk</a></figcaption></figure><p>IoT 장치들이 연결되고 상태를 관리하는 서비스로서 다음과 같은 기능을 제공합니다.</p><ul><li>연결된 디바이스를 등록하고 간편하게 권한을 관리하여 디바이스를 보호합니다.</li><li>AWS IoT 관점에서는 다양한 종류의 IoT 장치 연결이 가능하며 이러한 장치들을 분류하고 모니터링하는 기능을 제공합니다.</li><li>플릿(Fleet) 내 IoT 장치의 상태를 쿼리하고, 무선(OTA)으로 펌웨어 업데이트를 전송할 수 있습니다.</li></ul><h4>AWS IOT Core</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*CmmO1_idFbloFSeO_8hLng.png" /><figcaption>Source: <a href="https://www.youtube.com/watch?v=WAp6FHbhYCk">https://www.youtube.com/watch?v=WAp6FHbhYCk</a></figcaption></figure><p>IoT 센서들을 통해서 전달되는 데이터는 AWS IoT Core라고 불리는 메시지 브로커 서비스를 제공합니다. IoT 장치들은 별도의 IoT Core 연결에 필요한 보안 요구 사항을 충족하고 연결에 성공하면 AWS Lambda나 AWS Firehose와 같은 다양한 서비스로 메시지 라우팅이 가능합니다. 장치와 메시지의 수가 폭발적으로 늘어나도 이에 따른 별도의 인프라 구축에 대한 걱정 없이 바로 수용할 수 있다는 부분이 큰 장점이라고 할 수 있습니다.</p><h4>기타 다른 서비스들</h4><ul><li>AWS IoT Device Defender: 센서 플릿들을 감사 및 모니터링하여 각 디바이스에 대해 정상 동작으로 정의된 기준과 비교하여 문제 발생 시, 알림을 전송합니다.</li><li>FreeRTOS: AWS IoT에 연결 및 관리될 수 있는 장치를 활성화하기 위해서 특정 장치에 특화되어 설치 및 운용이 가능한 장치 소프트웨어입니다.</li><li>AWS IoT Analytics: 센서와 같은 IoT 장치를 통해서 수집된 데이터를 분석할 수 완전 관리형 서비스입니다.</li></ul><h4>장치 등록 및 메시지 처리</h4><p>AWS IoT 초기 작업에 필요한 장치 등록 및 메시지 처리 방법을 간단하게 확인해보았습니다. 장치 등록은 AWS 콘솔에서 간단하게 등록이 가능했습니다. 물론 이러한 과정은 AWS CLI를 통해서도 가능하지만 초기 구성 확인을 위해서 콘솔에서 진행했습니다. 장치 등록은 하나의 장치 연결과 여러 개의 장치를 한번에 연결하는 것 모두 가능했으며 하나의 장치를 가상으로 생성해서 시험을 진행했습니다. 장치 연결을 시작하면 다음과 같은 화면을 통해서 OS와 SDK 종류를 선택할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q8IXqSlshKa0VWzK" /><figcaption>AWS IOT 장치 연결 방법 선택</figcaption></figure><p>원하는 플래폼과 SDK를 선택하면 다음과 장치 연결에 필요한 파일 및 SDK를 다운받을 수 있습니다. 저의 경우에는 Linux/OSX와 Python을 선택했으며 장치명을 ‘hatiolab-test-device’로 설정하고 완료하면 다음과 같이 장치가 설정되어 있음을 확인할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QFwvZGlw1uIMxxJIsYBjLg.png" /><figcaption>장치 등록</figcaption></figure><p>위의 장치 등록 과정에서 다운받은 파일 내용은 다음과 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*3_moh7d6ojV1OBzZFWsztQ.png" /><figcaption>Linux/OSX Python 선택 시 다운로드 파일 구성</figcaption></figure><p>다운로드 받은 파일들은 해당 장치가 AWS IOT Core에 연결하기 위한 인증서 파일과 메시지 암호화에 사용되는 공개키(public key)와 사적 키(private key)로 구성됩니다. 이 파일들은 장치가 AWS IOT에 연결할 때 사용됩니다.</p><p>SDK를 통한 장치 연결은 위의 파일들 외에 다음과 같은 내용이 필요합니다.</p><ul><li>AWS IoT 연결에 필요한 엔드포인트 주소: 해당 주소는 AWS IoT 콘솔에서 Setting 메뉴에서 확인이 가능합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*MfOK4aAYDHs3g5HkvtH5SA.png" /><figcaption>AWS IOT Endpoint 확인</figcaption></figure><ul><li>AWS IoT Root CA certificate 파일은 다음과 같이 다운로드가 가능합니다.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bffdae058328fe8ce23f75e3e232e7bc/href">https://medium.com/media/bffdae058328fe8ce23f75e3e232e7bc/href</a></iframe><p>간단하게 준비된 파일들과 Python SDK를 통해서 메시지를 publish 하는 예제는 다음과 같습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/955a9a151c4c0c0ac3423e89f6ce3605/href">https://medium.com/media/955a9a151c4c0c0ac3423e89f6ce3605/href</a></iframe><p>위의 예제는 간단한 구조의 메시지를 주기적으로 pubilsh 및 subscribe할 수 있습니다. 또한 위의 코드를 통해서 전달된 메시지는 AWS IOT의 메시지 테스트 메뉴에서 확인하실 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Wv5YLsUXXmBBTsFk7_KFQ.png" /><figcaption>sdk/test/Python 토픽 메시지 퍼블리시 로그 화면</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CTPUtC_MTTeWUPj4VSVZyw.png" /><figcaption>AWS IOT에서 메시지 수신 확인</figcaption></figure><h3>앞으로..</h3><p>일반적으로 클라우드 환경에서 장치를 등록하고 제어하기 위해서는 등록된 장치의 관리, 메시지 핸들링, 오류 복구, 장치 개수 증가에 스케일링 등 다양한 부문에 걸쳐 관리 작업이 필요합니다. 이러한 문제들을 해결하기 위해서 클라우드 플래폼이 다양한 솔루션을 제공하고 있으며 AWS IoT 또한 잘 정돈되고 필요한 대부분의 기능을 만족하고 있는 솔루션이라고 생각됩니다. 하지만, 앞에서 확인한 것처럼 장치 제공자들은 AWS IoT에 접속하기 위해서는 AWS SDK를 기반으로 하거나 혹은 앞에서 언급된 OS를 제공하지 않는 마이크로 컨트롤러의 경우 AWS에서 제공하는 FreeRTOS를 포팅해야 연결이 가능할 것으로 보입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Y6NQAEyVokEYzQIdaSU3g.png" /><figcaption>FreeRTOS 적용 가능 하드웨어 플래폼 예</figcaption></figure><p>현재 저희가 사용하고 있는 센서 들도 이런한 장벽 때문에 바로 AWS IoT의 연결을 하지 못하고, 별도의 서버를 운용해서 센서 데이터를 처리하고 있습니다만, 앞으로 서비스가 본격화되고 사용자가 증가함에 따라서 이러한 클라우드 플래폼 IoT 서비스는 필수적일 것이라고 예상되고 있고, 장치 제공자와의 협업을 통해서 클라우드 연결성에 대한 부분을 확보하는 것이 중요할 것으로 판단하고 있습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e40484a88d5d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/aws-iot-%EC%84%9C%EB%B9%84%EC%8A%A4-%EA%B2%80%ED%86%A0-e40484a88d5d">AWS IOT 서비스 검토</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AIdoop-R — 협동 로봇 어플리케이션 개발 플래폼]]></title>
            <link>https://medium.com/hatiolab/aidoop-r-%ED%98%91%EB%8F%99-%EB%A1%9C%EB%B4%87-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EA%B0%9C%EB%B0%9C-%ED%94%8C%EB%9E%98%ED%8F%BC-4dd558b32bf5?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dd558b32bf5</guid>
            <category><![CDATA[web-framework]]></category>
            <category><![CDATA[robotics-automation]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Sun, 08 May 2022 09:42:17 GMT</pubDate>
            <atom:updated>2022-05-10T00:57:50.769Z</atom:updated>
            <content:encoded><![CDATA[<h3>AIdoop-R — 로봇 어플리케이션 개발 플래폼</h3><h3>로봇 어플리케이션?</h3><p><a href="https://m.blog.naver.com/angela8846/221969762170">로봇이 튀기는 미래형 치킨! 국내 1호, 식스센스에 나온 롸버트치킨의 맛은?</a></p><p>예전에 로봇은 산업용 로봇으로서 흔히 자동차와 같은 규모가 큰 대량 생산에 사용되는 자동화 로봇 등을 떠올렸으나 현재는 사람의 곁에서 사람의 업무의 일부를 대신하는 형태의 로봇이 소개되고 있고 또한 식당과 카페와 같은 소규모 업장에서도 사용 가능한 형태로 발전되어 가고 있습니다. 이와 같은 협동 로봇을 활용한 다양한 응용 어플리케이션의 가장 구체적인 예를 살펴보면 작년에 미디어에 많이 노출된 치킨 로봇을 예로 들 수 있습니다. 현재 소개된 여러 가지 관련 솔루션을 살펴보면 치킨 로봇의 주요 목적은 치킨을 튀기는 공정을 자동화하는 것이라고 볼 수 있습니다. 치킨 로봇의 동작을 살펴보면 사람 혹은 기계의 해서 완성된 반죽 재료가 바스켓에 올려지고 올려진 바스켓은 순번에 따라 대기하다가 로봇에 의해서 튀김기로 이동하고 일정 시간 튀겨진 닭은 다시 배출구로 로봇에 의해서 이동하는 이러한 과정 등을 반복하도록 되어 있습니다. 이러한 공정은 단순히 로봇에 의해서만 완성되는 것이 아니고 기름의 온도, 바스켓의 위치 등을 확인하기 위한 센서들, 컨베이어 등을 제어하기 위한 PLC와 같이 로봇의 튀김 공정을 순차적으로 실행하기 위해 필요한 많은 자원들로부터 오는 데이터들이 필요하고 이러한 데이터들을 기반으로 로봇들의 움직임이 결정되도록 구성됩니다.</p><p>로봇 어플리케이션의 특징을 요약하면 다음과 같습니다.</p><ul><li>로봇 어플리케이션에서는 로봇의 동작 제어 및 로봇의 현재 상태를 확인할 수 있어야 합니다. 이와 관련해서는 일반적으로 로봇 회사에서 제공하는 팬던트 등을 통해서 이동 명령을 저장하거나 혹은 별도의 외부 어플리케이션을 활용하기도 합니다.</li><li>협동 로봇 어플리케이션에서 로봇의 동작은 외부의 센서로부터 오는 다양한 정보를 기반으로 결정됩니다.</li><li>협동 로봇 어플리케이션은 로봇의 이동 속도 등이 제한되기 때문에 실시간의 빠른 업무 수행 능력을 요구하지 않습니다.</li><li>외부 센서 및 PLC와 같은 하드웨어 자원을 제어하기 위한 별도의 연결 관리가 필요합니다. 특히 PLC와의 통신을 위해서 모드버스(Modbus)나 PLC 메이커 전용 프로토콜 등의 지원도 필요합니다.</li><li>연결된 하드웨어 자원을 사용해서 로봇의 동작을 결정하기 위한 시나리오 로직 구현이 필요합니다. 예를 들면, 투입구에 튀김 바스켓의 존재 여부를 카메라 혹은 센서의 데이터로 판단하고 바스켓이 존재하고 현재 튀김 공정을 수행하지 않는 튀김기가 존재하지 않을 경우 바스켓을 튀김기로 이동하도록 로봇에게 명령을 요청해야 합니다. 이러한 시나리오 엔진은 로봇과 그 외 다른 하드웨어 자원과의 동기화를 맞추고 적시에 필요한 동작을 수행하도록 합니다.</li><li>로봇 어플리케이션의 동작 상태를 제어하고 확인할 수 있는 별도의 UI 어플리케이션이 필요합니다. 어플리케이션의 동작을 제어하고 로봇과 다른 하드웨어 자원에서 나오는 정보들을 출력하고 이상 여부를 감지합니다. 또한 어플리케이션의 특정 시나리오를 시작하거나 혹은 종료할 수 있는 인터렉션 기능을 제공합니다.</li></ul><h3>AIdoop-R</h3><p>AIdoop-R은 <a href="https://medium.com/hatiolab/things-factory-%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC-885741b1ca34">Things-Factory 프레임워크</a>을 기반으로, 앞에서 논의된 로봇 어플리케이션의 다양한 요구 사항을 구현하기 위한 많은 기능들을 제공하는 어플리케이션 플래폼입니다.</p><p><a href="https://medium.com/hatiolab/things-factory-%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC-885741b1ca34">Things-Factory 프레임워크</a></p><p>AIdoop-R은 로봇 어플리케이션 구현에 필요한 다양한 기능을 제공하며 다음과 같은 특징을 가지고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZHZjXIawYDvTzW2A.png" /><figcaption>AIdoop-R 개념 구성도</figcaption></figure><ul><li>로봇기반 응용 앱에 협동로봇, PLC, 카메라 등 장치연결 및 제어 용이</li><li>빠른 구현이 가능한 시나리오 모델링 툴과 장치별 다양한 태스크 제공</li><li>화면 모델링 툴과 UI 컴포넌트들을 활용, UI 및 인터렉션 구현 가능</li><li>고성능 서버부터 에지 디바이스까지 성능,플래폼 제약 없는 릴리즈 환경</li><li>카메라를 기반으로 하는 비전 솔루션 연동 가능</li></ul><h4>장치 연결 및 제어</h4><p>앞에서 언급한 것처럼 로봇 어플리케이션은 다양한 하드웨어 혹은 통신 기반의 자원을 기반으로 구성되는 것이 일반적입니다. 센서, 로봇, PLC 등의 하드웨어 자원을 하나의 화면에서 연결 상태를 제어하고 관리할 수 있습니다. 또한 개별 자원마다 지원되는 다양한 파라미터를 변경하고 관리할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUbEhGDnToZUPLI18Fhq9w.png" /><figcaption>장치 연결 및 제어 화면</figcaption></figure><h4>시나리오 엔진</h4><p>어플리케이션 구현에 필요한 다양한 자원의 연결 및 초기화가 완료되면 실제 로봇 어플리케이션 구현에 필요한 시나리오를 생성하고 관리할 수 있는 기능을 제공합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2YPfCFllVgRy6Ix282J4FA.png" /><figcaption>시나리오 리스트 및 구성 화면</figcaption></figure><ul><li>연결된 개별 자원들을 기반으로 다양한 태스크가 제공됩니다. 예를 들면 로봇의 경우에는 해당 로봇 좌표로 이동, 로봇 리셋, 로봇의 I/O 포트 제어 등의 태스크가 제공됩니다. 그리퍼 태스크의 경우에는 당연히 그리퍼의 열기, 닫기 등의 태스크를 제공합니다.</li><li>시나리오 내에서 다른 시나리오의 호출, 특정 태스크로의 분기, 일정 시간 지연(sleep)과 같은 시나리오 흐름 구성에 필요한 태스크를 제공하며, 동시에 여러 시나리오가 호출될 수 있으며 이러한 시나리오의 순번을 제어하기 위한 큐 기능을 제공합니다.</li><li><strong>프로그래밍에 대한 지식 없이도 단순 시간 순으로 태스크를 배열하는 것만으로 어플리케이션의 로직을 구현</strong>할 수 있으며, 단순 태스크 배열 만으로도 복잡한 어플리케이션 구조를 설계 구현할 수 있는 다양한 장치 들을 마련하고 있습니다.</li><li>시나리오 구성은 앞으로 소개할 화면 제작 기능과 연계해서 다양한 종류의 화면을 구성하는데 사용됩니다.</li></ul><h4>화면 제작</h4><p>AIdoop-R은 화면 제작 도구로서 파워포인트와 같은 상용 어플리케이션에서 제공하는 화면 제작 기능을 내장하고 있습니다.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FHxpOo6ImPYI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DHxpOo6ImPYI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FHxpOo6ImPYI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea78222a846c592808999efa36b4a12a/href">https://medium.com/media/ea78222a846c592808999efa36b4a12a/href</a></iframe><p>화면 제작 도구를 기반으로 다양한 화면 구성 및 효과를 표현할 수 있으며, 3D 기반 보드 구성도 가능합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jy0RssVp-oGSJWCw5bqvUw.png" /><figcaption>화면 제작 도구-다양한 차트 표현</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ovyxUYw1YzXPv_xAjc1OA.png" /><figcaption>3D 보드 구성 예</figcaption></figure><h4>웹 기반 어플리케이션 플래폼</h4><p>로봇 어플리케이션을 구현에 필요한 많은 기능들을 제공하는 AIdoop-R은 웹 기반 어플리케이션 플래폼입니다. 웹 기반 어플리케이션 플래폼이 가지는 장점은 다음과 같습니다.</p><ul><li><strong>도커 기반의 서버 설치가 가능하여 간단한 스크립트 실행 정도만으로 설치가 완료</strong>됩니다.</li><li>OS에 대한 의존성이 없습니다. Linux 기반으로 구현된 어플리케이션을 안드로이드로 포팅을 고려하는 등의 이러한 고민 자체가 전혀 의미가 없습니다. 웹 브라우저 설치가 가능한 플래폼이라면 바로 서버에 접근해서 어플리케이션 사용이 가능합니다. 이는 <strong>PC 형태의 어플리케이션 운용 뿐만 아니라 모바일 단말기 운용을 고려하고 있을 경우 하나의 솔루션으로 커버</strong>할 수 있습니다.</li><li>AIdoop-R은 Things-Factory 프레임워크를 기반으로 구현되어 있어 PWA(Progressive Web Application) 기능을 내재하고 있어 <strong>일반 어플리케이션과 동일하게 설치되어 실행되고 일반적인 웹 서버 연결과 달리 빠르고 가볍게 동작</strong>합니다.</li></ul><h4>쉽게 접근하고 바로 사용 가능한..</h4><p>AIdoop-R은 현재 튀김 로봇, 카페 로봇, 피킹앤 플레이스 등의 로봇을 활용한 다양한 분야에서 점진적으로 사용되고 있습니다. 로봇 어플리케이션에 필요한 요구 사항을 분석하고 다양한 분야에서 활용을 위한 태스크 개발을 진행하고 있습니다. 앞으로 로봇 응용 어플리케이션 개발에 있어서 누구나 쉽게 접근하고 바로 사용 가능한 대중적인 어플리케이션 플래폼으로 성장하는 것을 목표로 하고 있습니다.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPpiiRn9HYAc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPpiiRn9HYAc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPpiiRn9HYAc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/941482c3f86b49e3f671a326a8bb4673/href">https://medium.com/media/941482c3f86b49e3f671a326a8bb4673/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMwKYw2c7464%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMwKYw2c7464&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMwKYw2c7464%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5ca4dc8c94d3724d362b32467ab844f/href">https://medium.com/media/f5ca4dc8c94d3724d362b32467ab844f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGM9cynRbqlY%3Fstart%3D3%26feature%3Doembed%26start%3D3&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGM9cynRbqlY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGM9cynRbqlY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/409d0ef33521e2cb9bb900e098079862/href">https://medium.com/media/409d0ef33521e2cb9bb900e098079862/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dd558b32bf5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/aidoop-r-%ED%98%91%EB%8F%99-%EB%A1%9C%EB%B4%87-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EA%B0%9C%EB%B0%9C-%ED%94%8C%EB%9E%98%ED%8F%BC-4dd558b32bf5">AIdoop-R — 협동 로봇 어플리케이션 개발 플래폼</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[우리가 카프카(Kafka)를 사용하는 이유]]></title>
            <link>https://medium.com/hatiolab/%EC%9A%B0%EB%A6%AC%EA%B0%80-%EC%B9%B4%ED%94%84%EC%B9%B4-kafka-%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0-a73820984c25?source=rss-d72fdecaf747------2</link>
            <guid isPermaLink="false">https://medium.com/p/a73820984c25</guid>
            <category><![CDATA[cdc]]></category>
            <category><![CDATA[web-framework]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[cloud-services]]></category>
            <dc:creator><![CDATA[Jinwon]]></dc:creator>
            <pubDate>Sun, 01 May 2022 11:37:19 GMT</pubDate>
            <atom:updated>2022-05-02T02:13:58.564Z</atom:updated>
            <content:encoded><![CDATA[<h3>왜 카프카?</h3><p>저희가 구축하고 있는 클라우드 서비스의 구성을 아래의 구성도와 함께소개하면 가장 많이 듣는 질문이 있습니다.</p><blockquote>현재 진행되고 있는 OpeatoChef서비스의 경우 빅데이터 기반의 서비스도 아니고 데이터 처리의 연속성이나 실시간성을 요구하는 것도 아니면서 왜 Kafka를 기반으로 CDC를 구축하나요?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/0*eDoyDWLxtY8sAdXw.png" /><figcaption>Things-Factory 클라우드 서비스 구성도</figcaption></figure><p>카프카는 단순한 이벤트 브로커나 서비스 버스의 역할, 데이터 저장소의 역할 할로서도 사용 가능하지만, 저희는 카프카가 클라우드 서비스를 통해서 제공되는 다양한 서비스들을 하나의 기반 서비스로 빚어낼 수 있는 스트리밍 플래폼으로서의 역할을 기대하고 있습니다. Things-Factory 프레임워크의 모듈들이 점진적으로 마이크로 서비스 아키텍처(Micro Service Architecture, 이하 MSA)로 진화하기 위한 기반 서비스로서 카프카가 활용될 것으로 바라보고 있습니다. 카프카가 가지고 있는 플래폼의 역할을 수행하기 위한 다양한 특징이 있으며 이와 관련해서 알아보고자 합니다.</p><h3>카프카를 활용하기 위한 다양한 API들</h3><p>카프카는 스트리밍 프로세싱에 있어서 다음과 같은 3 종류의 API를 제공할 수 있습니다.</p><ul><li>Kafka Streams</li><li>KSQL</li><li>Connect</li></ul><p>Kafka Streams와 KSQL API는 데이터베이스 엔진으로서 데이터 스트림에 대한 필터 기능, 데이터의 가공(join, aggregation), 상태 저장, 데이터 플로를 위한 다양한 기능을 제공합니다. 이와 같은 API의 특징은 stateful하며 우리가 알고 있는 일반적인 데이터베이스와 같이 테이블과 같은 형태로 데이터를 관리합니다.</p><p>반면 Connect API는 카프카가 다른 서비스와 구별되는 특징 중 하나로서 다른 데이터베이스나 다른 종류의 서비스들과 카프카를 연결하는 인터페이스의 역할을 제공합니다. 이러한 Connect API를 이용해서 카프카를 중심으로 하는 데이터 기반 생태계 구축이 가능합니다. Connect API를 통해서 구현된 다양한 third-part connector들은 카프카 서비스의 선두주자인 Confluent에서 지원되는 connector 리스트를 통해서 다음 URL에서 확인이 가능합니다(<a href="https://docs.confluent.io/5.2.0/connect/managing/connectors.html">https://docs.confluent.io/5.2.0/connect/managing/connectors.html</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*xJLCfAEH7l8S_Y055oPYnA.png" /><figcaption>카프카의 스트리밍 플래폼 구성 요소 (Fig 3–1, Designing Event-Drive Systems — Concepts and Patterns for Streaming Serices with Apache Kafka, Ben Stopford, 2018, O’Reilly Media)</figcaption></figure><h3>카프카 주요 특징</h3><p>카프카 서비스 제공에 대표 주자인 Confluent에서 무료로 배포하고 있는 ‘Designing Event-Drive Systems — Concepts and Patterns for Streaming Services with Apache Kafka’에서 소개하는 내용을 축약해서 다음과 같이 정리해 보고자 합니다.</p><h4>데이터 유지와 배분에 특화된 로그 메시지 구조</h4><p>카프카 메시징 시스템의 중심에는 분할되지만 재생 가능한 로그 방식의 메시지 구조에 있습니다. 메시지를 읽으려고 할 때 마지막으로 읽은 메시지의 위치를 지속적으로 기록하면 메시지를 도착한 순서대로 읽습니다. 이러한 순차적 읽기와 쓰기 방식을 기반으로 데이터는 디스크 버퍼에서 네트워크 버퍼로 직접 복사되고 카프카에서 관리하는 별도의 저장 위치나 메모리에 복사되지 않기 때문에 전체적으로 높은 데이터 성능 처리 능력을 가지게 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*BHa6USIMajEpo_xOVlc3YA.png" /><figcaption>카프카 로그 방식의 메시지 처리(Append Only) (Fig 4–1, Designing Event-Drive Systems — Concepts and Patterns for Streaming Serices with Apache Kafka, Ben Stopford, 2018, O’Reilly Media)</figcaption></figure><p>기존의 메시지 브로커는 메시지 헤더를 처리하고, 읽은 메시지를 제거하기 위해서 인덱스 구조(해시 테이블 혹은 B-트리)를 가집니다. 이러한 구조는 인덱스를 유지 관리 하기 위해서 성능 측면과 리소스 측면에서 비용이 필요합니다. 하지만 카프카와 같은 로그 메시지 구조는 별도의 인덱스 관리에 대한 필요가 없이 모든 읽기와 쓰기가 마지막 위치를 기준으로 순차적으로 이루어집니다. 이러한 방식은 서비스에 장기간 메시지를 읽지 않아도 순차적인 방식으로 저장되는 특성 상 성능 상에 별다른 문제가 발생하지 않고, 서비스 내에서 이벤트 소싱으로서의 역할 수행에 장점을 가지고 있습니다.</p><h4>확장성(Linear Scalability)</h4><p>카프카는 무한 확장 가능한 클러스터 구축이 가능하도록 설계되어 있습니다. 위에서 소개한 메시지 저장 방식이 파티션이라고 불리우는 논리적인 저장 개체에 저장되지만 하나의 토픽은 여러 개의 파티션에 분산 저장이 가능하고 파티션은 또한 하나의 물리 시스템이 아니고 분리되어 있는 시스템에 분산되어 저장됩니다. 이와 같은 아키텍처의 주요 이점은 데이터의 대역폭 및 이동에 대한 한계 고민을 없애 줄 수 있으며 보다 자유로운 방식으로 서비스 설계가 가능해집니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*d_8fejd5gb8NVNM1skBe-w.png" /><figcaption>Producer와 Consumer 예 (Fig 4–2, Designing Event-Drive Systems — Concepts and Patterns for Streaming Serices with Apache Kafka, Ben Stopford, 2018, O’Reilly Media)</figcaption></figure><h4>마이크로서비스 관점에서의 로드 밸런싱</h4><p>클라우드 서비스 아키텍처의 특성 상 보통 다중 테넌트로 구성됩니다. 그러므로 단일 클러스터 서비스가 다양한 서비스에 사용되는 경우가 빈번하며 이러한 구조로 인해서 서비스 성능 저하를 유발하는 다양한 임의의 공격에 노출될 수 있습니다. 이러한 기능에 도움을 줄 수 있도록 카프카는 처리량 제어 기능을 가지고 있습니다. 그래서 단일 클러스터 내의 서비스들이 특정한 데이터들이 일정한 처리량을 초과하지 않도록 관리가 가능합니다. 이러한 서비스의 특정은 단일 클러스터의 여러 서비스에 대한 로드 밸런싱을 가능하게 합니다.</p><h4>메시지 정렬</h4><p>카프카와 같이 메시메시지의 순서가 중요한 서비스의 경우를 위해서 카프카는 파티션에 대한 정책을 통해서 별도의 관리가 가능합니다. 즉, 메시지의 누락 방지 뿐만 아니라 메시지의 순서가 도착한 순서대로 관리되어야 할 경우에는 해당 토픽의 메시지가 하나의 파티션에만 라우팅되어 저장되도록 함으로서 메시지를 도착 순서대로 관리됩니다. 또한 메시지가 임의의 이유로 처리되지 못할 경우에는 별도의 DLQ(Dead Letter Queue)를 기반으로 처리할 수 있습니다.</p><h4>메시지 내구성</h4><p>카프카는 파티션을 기반으로 복제를 통해 내구성을 제공합니다. 클러스터 초기 구성 시에 복제본의 개수를 설정함으로서 카프카에 도착한 메시지는 설정에 의해서 복제됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/0*VNhz227MINm6b_LE.png" /><figcaption>참고. <a href="https://velog.io/@jwpark06/Kafka-%EC%8B%9C%EC%8A%A4%ED%85%9C-%EA%B5%AC%EC%A1%B0-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0">https://velog.io/@jwpark06/Kafka-%EC%8B%9C%EC%8A%A4%ED%85%9C-%EA%B5%AC%EC%A1%B0-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0</a></figcaption></figure><p>위의 그림과 같이 카프카 클러스터는 아파치 주키퍼에 의해서 개별 브로커들이 관리되고 각 브로커 내에는 토픽 별로 기본 데이터 저장 파티션(Leader)와 복제 파티션(Follower)로 구성되면 모든 데이터는 복제 파티션에 데이터가 복사 저장됩니다. 그로 인해서 하나의 브로커가 운용 불능 상태가 되더라고 지속적으로 해당 토픽에 대한 작업이 가능해 집니다.</p><h4>고가용성</h4><p>카프카의 고가용성의 핵심은 앞에서 소개한 파티션 기반의 데이터 저장 방식이며 컨슈머 입장에서 반드시 하나의 엔드포인트(파티션)을 통해서만 바라보지 않아도 여러 엔드포인트(파티션)에서 데이터를 받아서 처리가 가능해 집니다.</p><h4>토픽 기반의 데이터 저장</h4><p>카프카는 토픽 단위로 메시지를 미리 설정되어 있는 기간 동안 토픽을 저장합니다. 저장된 토픽은 주기적으로 스캔되며, 기존의 메시지가 대체된 경우를 관리하기 위한 별도의 메카니즘을 가지고 있습니다. 이와 같이 별도의 토픽을 저장하기 위해서 별도의 스토리지 계층을 가지고 있습니다.</p><p>카프카는 데이터베이스가 아닙니다. 광범위한 쿼리 기능은 제공하지 않는 커밋 로그(Commit Log)입니다.하지만 이렇게 일정 기간 저장되어 있는 데이터는 감사 또는 이벤트 소싱에 적합하며 Kafka Streams를 사용하여 일정 기간의 데이터 스트림에 대한 별도의 필터, 판단, 예측 등의 작업을 수행할 수 있습니다.</p><h4>보안</h4><p>카프카는 인증 및 권한 부여에 있어서 엔터프라이즈급 보안 기능을 제공합니다. 클라이언트 인증은 Kerberos 또는 TLS 클라이언트 인증서를 통해 제공되어 카프카 클러스터가 요청자 신원을 확인할 수 있습니다. 또한 데이터에 접근하기 위한 권한 시스템 사용이 가능하고, 네트워크 패킷을 암호화하여 신뢰할 수 없는 네트워크에서도 메시지를 안전하게 전송할 수 있습니다.</p><h3>Things-Factory 클라우드 서비스에서는..</h3><p>Things-Factory 클라우드 서비스는 앞에서 살펴본 카프카의 특성을 통해서 다음과 같은 장점을 가져가고 있습니다.</p><ul><li>카프카는 마이크로서비스 아키텍처 구성의 데이터 스트림 플래폼을 담당하고 있습니다. 플래폼이라고 명명한 이유는 단순한 메시지 브로커로서가 아니라 앞으로 구성될 다양한 서비스를 연결하는 플래폼으로서 큰 의의를 가지고 있기 때문입니다.</li><li>Things-Factory 클라우드 서비스는 앞으로 다양한 어플리케이션 구축에 활용되는 플래폼으로서 몇 개의 어플리케이션에 국한되지 않는 확장성을 가지려고 합니다. 이러한 확장성 구축에 있어서 카프카가 가지고 있는 데이터 로드 밸런싱 능력과 주키퍼를 통해서 제공되는 고가용성을 클라우드 서비스의 장점으로 가져오려고 하고 있습니다.</li><li>멀티 테넌시 기반의 서비스에 있어서 가장 중요한 보안과 데이터 내구성 측면에서 카프카가 가지고 있는 장점을 활용하고자 합니다. 이를 통해 기존 프레임워크에서 모노로식 구조에서는 고려하지 않았던 서비스 간의 데이터 신뢰성을 확보해 나가고 있습니다.</li></ul><h3>참고 자료</h3><ul><li>Designing Event-Drive Systems — Concepts and Patterns for Streaming Services with Apache Kafka, Ben Stopford, 2018, O’Reilly Media</li><li><a href="https://jeongjin984.github.io/posts/Data-Engineering-Kafka/">https://jeongjin984.github.io/posts/Data-Engineering-Kafka/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a73820984c25" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hatiolab/%EC%9A%B0%EB%A6%AC%EA%B0%80-%EC%B9%B4%ED%94%84%EC%B9%B4-kafka-%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0-a73820984c25">우리가 카프카(Kafka)를 사용하는 이유</a> was originally published in <a href="https://medium.com/hatiolab">hatiolab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>