본문 바로가기

카테고리 없음

42. 클라우드 네이티브 Go 실습 4편

  • gRPC는 구글이 최초로 개발한 오픈 소스 원격 프로시저 호출 시스템이다. 전송을 위해 HTTP/2를, 인터페이스 정의 언어로 프로토콜 버퍼를 사용하며 인증, 양방향 스트리밍 및 흐름 제어, 차단 및 비차단 바인딩, 취소 및 타임아웃 등의 기능을 제공
  • Apache Beam은 배치와 실시간 데이터 파이프라인을 개발하고, 다양한 런타임 환경을 지원
  • Go-kit는 마이크로서비스 프레임워크이고 다양한 마이크로서비스 디자인 패턴을 지원
  • Mongo는 가장 유명한 NoSQL이고 JSON의 관리 및 집계에 유용
  • Redis는 가장 유명한 캐시 저장소
  • Tracing는 관찰가능성 중 분산추적을 위한 프레임워크를 제공
  • Echo는 웹 어플리케이션 프레임워크이고 Air와 함께 auto reload를 지원
  • MySQL은 오픈소스 RDBMS
  • GORM은 Go언어에서 사용 가능한 ORM(Object Relation Mapping) 라이브러리
  • Operator는 사용자 정의 리소스의 컨트롤러 역할을 수행하며, 쿠버네티스 자원에 대한 멱등성을 구현
  • Exporter는 다양한 시스템으로부터 메트릭을 수집해서 프로메테우스에게 제공
  • RealWorld은 Echo, GORM 등을 사용한 레퍼런스 데모를 제공

4편에서는 Operator를 데모하고 설명한다.

10. Operator

Go 설치

root@philip-virtual-machine:~/operator-sdk# wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz
root@philip-virtual-machine:~/operator-sdk# tar -xvf go1.16.5.linux-amd64.tar.gz

Go 설정

root@philip-virtual-machine:~# export GOROOT=/root/go
root@philip-virtual-machine:~# export GOPATH=/root/go/space
root@philip-virtual-machine:~# export PATH=$GOROOT/bin:/root/go/space/bin:$PATH

operator-sdk 설치

[root@localhost gorm]# git clone https://github.com/operator-framework/operator-sdk
Cloning into 'operator-sdk'...
remote: Enumerating objects: 44573, done.
remote: Counting objects: 100% (124/124), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 44573 (delta 45), reused 107 (delta 33), pack-reused 44449
Receiving objects: 100% (44573/44573), 64.16 MiB | 11.55 MiB/s, done.
Resolving deltas: 100% (25984/25984), done.
[root@localhost gorm]# cd operator-sdk
[root@localhost operator-sdk]# git checkout master
Already on 'master'
[root@localhost operator-sdk]# make install
go install -gcflags "all=-trimpath=/root/gorm" -asmflags "all=-trimpath=/root/gorm" -ldflags " -X 'github.com/operator-framework/operator-sdk/internal/version.Version=v1.15.0+git' -X 'github.com/operator-framework/operator-sdk/internal/version.GitVersion=v1.15.0-17-g5d8d0e6' -X 'github.com/operator-framework/operator-sdk/internal/version.GitCommit=5d8d0e6edef379c5222ba1d796a9349e4220641a' -X 'github.com/operator-framework/operator-sdk/internal/version.KubernetesVersion=v1.21' -X 'github.com/operator-framework/operator-sdk/internal/version.ImageVersion=v1.15.0' "  ./cmd/{operator-sdk,ansible-operator,helm-operator}

operator-sdk 설치 확인

root@philip-virtual-machine:~/go/space/bin# ll
합계 190900
drwxr-xr-x 2 root root     4096  1월 12 17:03 ./
drwxr-xr-x 4 root root     4096  1월 12 17:03 ../
-rwxr-xr-x 1 root root 51489789  1월 12 17:05 ansible-operator*
-rwxr-xr-x 1 root root 66778354  1월 12 17:05 helm-operator*
-rwxr-xr-x 1 root root 77199291  1월 12 17:05 operator-sdk*
root@philip-virtual-machine:~/go/space/bin# pwd
/root/go/space/bin

프로젝트 초기화

[root@localhost operator-sdk]# mkdir memcached-operator
[root@localhost operator-sdk]# cd memcached-operator
[root@localhost memcached-operator]# operator-sdk init --domain example.com --repo github.com/example/memcached-operator
Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.10.0
go: downloading k8s.io/apimachinery v0.22.1
go: downloading k8s.io/client-go v0.22.1
go: downloading k8s.io/utils v0.0.0-20210802155522-efc7438f0176
go: downloading k8s.io/api v0.22.1
go: downloading k8s.io/apiextensions-apiserver v0.22.1
go: downloading golang.org/x/net v0.0.0-20210520170846-37e1c6afe023
go: downloading k8s.io/component-base v0.22.1
go: downloading github.com/google/go-cmp v0.5.5
go: downloading golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
go: downloading golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2
go: downloading google.golang.org/appengine v1.6.7
go: downloading github.com/evanphx/json-patch v0.5.2
go: downloading k8s.io/client-go v1.5.2
Update dependencies:
$ go mod tidy
go: downloading go.uber.org/goleak v1.1.10
go: downloading github.com/benbjohnson/clock v1.1.0
go: downloading gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f
go: downloading github.com/Azure/go-autorest/autorest/mocks v0.4.1
go: downloading golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
go: downloading cloud.google.com/go v0.54.0
go: downloading golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
go: downloading github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e
go: downloading golang.org/x/tools v0.1.2
Next: define a resource with:
$ operator-sdk create api
[root@localhost memcached-operator]#

API 생성

[root@localhost memcached-operator]# operator-sdk create api --group cache --version v1alpha1 --kind Memcached --resource --controller
Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
api/v1alpha1/memcached_types.go
controllers/memcached_controller.go
Update dependencies:
$ go mod tidy
Running make:
$ make generate
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0
go: downloading golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
go get: added sigs.k8s.io/controller-tools v0.7.0
/root/gorm/operator-sdk/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
Next: implement your new API and generate the manifests (e.g. CRDs,CRs) with:
$ make manifests
[root@localhost memcached-operator]#

 ---> [Warning] IPv4 forwarding is disabled. Networking will not work. 에러 발생 시, 도커 재시작

도커 이미지 생성

[root@localhost memcached-operator]# systemctl restart docker
root@philip-virtual-machine:~/go/space/bin/memcached-operator# make docker-build docker-push IMG="yohaim1511/memcached-operator:v0.0.3"
/root/go/space/bin/memcached-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/root/go/space/bin/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
go: downloading sigs.k8s.io/controller-runtime v0.11.0
go: downloading sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20220104140252-e52a8b1fba62
go: downloading github.com/go-logr/zapr v1.2.0
go: downloading go.uber.org/zap v1.19.1
go: downloading github.com/go-logr/logr v1.2.0
go get: added sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20220104140252-e52a8b1fba62
KUBEBUILDER_ASSETS="/root/.local/share/kubebuilder-envtest/k8s/1.22.1-linux-amd64" go test ./... -coverprofile cover.out
?   	github.com/example/memcached-operator	[no test files]
?   	github.com/example/memcached-operator/api/v1alpha1	[no test files]
ok  	github.com/example/memcached-operator/controllers	8.686s	coverage: 0.0% of statements
docker build -t yohaim1511/memcached-operator:v0.0.3 .
Sending build context to Docker daemon  166.4kB
Step 1/14 : FROM golang:1.16 as builder
1.16: Pulling from library/golang
0e29546d541c: Pull complete 
9b829c73b52b: Pull complete 
cb5b7ae36172: Pull complete 
6494e4811622: Pull complete 
6e1d20a8313e: Pull complete 
5b59121a0c35: Pull complete 
2db41f0db9d9: Pull complete 
Digest: sha256:76bd1697c82f6027cb7d2086869fd81443adb7f780ae16c87860a212cdc2bc0b
Status: Downloaded newer image for golang:1.16
 ---> 71f1b47263fc
Step 2/14 : WORKDIR /workspace
 ---> Running in c14604e4d1a2
Removing intermediate container c14604e4d1a2
 ---> 92ad7ad1a4e3
Step 3/14 : COPY go.mod go.mod
 ---> 53b4736635ce
Step 4/14 : COPY go.sum go.sum
 ---> b7157d29ca4a
Step 5/14 : RUN go mod download
 ---> Running in 877ae163f16e
Removing intermediate container 877ae163f16e
 ---> 4a691f57d6b0
Step 6/14 : COPY main.go main.go
 ---> bbd363b8463c
Step 7/14 : COPY api/ api/
 ---> 95723c11ec62
Step 8/14 : COPY controllers/ controllers/
 ---> dffd7030842a
Step 9/14 : RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
 ---> Running in 7c53e9b4934b
Removing intermediate container 7c53e9b4934b
 ---> 99b90f31a8c0
Step 10/14 : FROM gcr.io/distroless/static:nonroot
nonroot: Pulling from distroless/static
2df365faf0e3: Already exists 
Digest: sha256:80c956fb0836a17a565c43a4026c9c80b2013c83bea09f74fa4da195a59b7a99
Status: Downloaded newer image for gcr.io/distroless/static:nonroot
 ---> 5bc88c360b3e
Step 11/14 : WORKDIR /
 ---> Running in f7983951364b
Removing intermediate container f7983951364b
 ---> 53899e0f2ac8
Step 12/14 : COPY --from=builder /workspace/manager .
 ---> dec8be1bc038
Step 13/14 : USER 65532:65532
 ---> Running in 53e13a82f554
Removing intermediate container 53e13a82f554
 ---> 55eddec420b3
Step 14/14 : ENTRYPOINT ["/manager"]
 ---> Running in 88a2136ffced
Removing intermediate container 88a2136ffced
 ---> a954ae3fc9b1
Successfully built a954ae3fc9b1
Successfully tagged yohaim1511/memcached-operator:v0.0.3
docker push yohaim1511/memcached-operator:v0.0.3
The push refers to repository [docker.io/yohaim1511/memcached-operator]
1e3db65b7f75: Pushed 
5b1fa8e3e100: Layer already exists 
v0.0.3: digest: sha256:0f29568028faf6cd244fe4361d2eab7dbfd6bc43f744205de2d3bc29b4dc8b5b size: 739

 

미니쿠베 재시작

root@philip-virtual-machine:~/go/space/bin# minikube stop
root@philip-virtual-machine:~/go/space/bin# minikube start --vm-driver=none

OLM 설치

root@philip-virtual-machine:~/go/space/bin# ./operator-sdk olm install
INFO[0000] Fetching CRDs for version "latest"           
INFO[0000] Fetching resources for resolved version "latest" 
I0112 17:11:20.183141   48405 request.go:665] Waited for 1.048038172s due to client-side throttling, not priority and fairness, request: GET:https://192.168.17.133:8443/apis/extensions/v1beta1?timeout=32s
INFO[0013] Creating CRDs and resources                  
INFO[0013]   Creating CustomResourceDefinition "catalogsources.operators.coreos.com" 
INFO[0013]   Creating CustomResourceDefinition "clusterserviceversions.operators.coreos.com" 
INFO[0013]   Creating CustomResourceDefinition "installplans.operators.coreos.com" 
INFO[0013]   Creating CustomResourceDefinition "olmconfigs.operators.coreos.com" 
INFO[0013]   Creating CustomResourceDefinition "operatorconditions.operators.coreos.com" 
INFO[0013]   Creating CustomResourceDefinition "operatorgroups.operators.coreos.com" 
INFO[0013]   Creating CustomResourceDefinition "operators.operators.coreos.com" 
INFO[0013]   Creating CustomResourceDefinition "subscriptions.operators.coreos.com" 
INFO[0013]   Creating Namespace "olm"                   
INFO[0013]   Creating Namespace "operators"             
INFO[0013]   Creating ServiceAccount "olm/olm-operator-serviceaccount" 
INFO[0013]   Creating ClusterRole "system:controller:operator-lifecycle-manager" 
INFO[0013]   Creating ClusterRoleBinding "olm-operator-binding-olm" 
INFO[0013]   Creating OLMConfig "cluster"               
I0112 17:11:30.634047   48405 request.go:665] Waited for 1.048398872s due to client-side throttling, not priority and fairness, request: GET:https://192.168.17.133:8443/apis/admissionregistration.k8s.io/v1beta1?timeout=32s
INFO[0017]   Creating Deployment "olm/olm-operator"     
INFO[0017]   Creating Deployment "olm/catalog-operator" 
INFO[0017]   Creating ClusterRole "aggregate-olm-edit"  
INFO[0017]   Creating ClusterRole "aggregate-olm-view"  
INFO[0017]   Creating OperatorGroup "operators/global-operators" 
INFO[0017]   Creating OperatorGroup "olm/olm-operators" 
INFO[0017]   Creating ClusterServiceVersion "olm/packageserver" 
INFO[0018]   Creating CatalogSource "olm/operatorhubio-catalog" 
INFO[0018] Waiting for deployment/olm-operator rollout to complete 
INFO[0018]   Waiting for Deployment "olm/olm-operator" to rollout: 0 of 1 updated replicas are available 
INFO[0032]   Deployment "olm/olm-operator" successfully rolled out 
INFO[0032] Waiting for deployment/catalog-operator rollout to complete 
INFO[0032]   Deployment "olm/catalog-operator" successfully rolled out 
INFO[0032] Waiting for deployment/packageserver rollout to complete 
INFO[0032]   Waiting for Deployment "olm/packageserver" to rollout: 0 of 2 updated replicas are available 
INFO[0057]   Deployment "olm/packageserver" successfully rolled out 
INFO[0057] Successfully installed OLM version "latest"  

NAME                                            NAMESPACE    KIND                        STATUS
catalogsources.operators.coreos.com                          CustomResourceDefinition    Installed
clusterserviceversions.operators.coreos.com                  CustomResourceDefinition    Installed
installplans.operators.coreos.com                            CustomResourceDefinition    Installed
olmconfigs.operators.coreos.com                              CustomResourceDefinition    Installed
operatorconditions.operators.coreos.com                      CustomResourceDefinition    Installed
operatorgroups.operators.coreos.com                          CustomResourceDefinition    Installed
operators.operators.coreos.com                               CustomResourceDefinition    Installed
subscriptions.operators.coreos.com                           CustomResourceDefinition    Installed
olm                                                          Namespace                   Installed
operators                                                    Namespace                   Installed
olm-operator-serviceaccount                     olm          ServiceAccount              Installed
system:controller:operator-lifecycle-manager                 ClusterRole                 Installed
olm-operator-binding-olm                                     ClusterRoleBinding          Installed
cluster                                                      OLMConfig                   Installed
olm-operator                                    olm          Deployment                  Installed
catalog-operator                                olm          Deployment                  Installed
aggregate-olm-edit                                           ClusterRole                 Installed
aggregate-olm-view                                           ClusterRole                 Installed
global-operators                                operators    OperatorGroup               Installed
olm-operators                                   olm          OperatorGroup               Installed
packageserver                                   olm          ClusterServiceVersion       Installed
operatorhubio-catalog                           olm          CatalogSource               Installed

OLM 전개

root@philip-virtual-machine:~/go/space/bin/memcached-operator# make bundle IMG="yohaim1511/memcached-operator:v0.0.3"
/root/go/space/bin/memcached-operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/kustomize/kustomize/v3@v3.8.7
go: downloading sigs.k8s.io/kustomize/kustomize/v3 v3.8.7
go: downloading k8s.io/client-go v0.18.10
go: downloading sigs.k8s.io/kustomize/api v0.6.5
go: downloading github.com/spf13/cobra v1.0.0
go: downloading sigs.k8s.io/kustomize/cmd/config v0.8.5
go: downloading github.com/evanphx/json-patch v4.9.0+incompatible
go: downloading k8s.io/apimachinery v0.18.10
go: downloading gopkg.in/yaml.v2 v2.3.0
go: downloading github.com/yujunz/go-getter v1.4.1-lite
go: downloading sigs.k8s.io/kustomize/kyaml v0.9.4
go: downloading github.com/olekukonko/tablewriter v0.0.4
go: downloading github.com/gogo/protobuf v1.3.1
go: downloading k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
go: downloading sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e
go: downloading k8s.io/api v0.18.10
go: downloading github.com/hashicorp/go-multierror v1.1.0
go: downloading github.com/go-openapi/jsonpointer v0.19.3
go: downloading sigs.k8s.io/structured-merge-diff/v3 v3.0.0
go: downloading github.com/go-openapi/jsonreference v0.19.3
go: downloading github.com/go-openapi/swag v0.19.5
go: downloading github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d
go: downloading github.com/hashicorp/go-cleanhttp v0.5.0
go: downloading github.com/hashicorp/go-safetemp v1.0.0
go: downloading github.com/hashicorp/go-version v1.1.0
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/mitchellh/go-testing-interface v1.0.0
go: downloading github.com/ulikunitz/xz v0.5.5
go: downloading github.com/stretchr/testify v1.6.1
go: downloading github.com/go-openapi/strfmt v0.19.5
go: downloading github.com/go-openapi/validate v0.19.8
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading github.com/mailru/easyjson v0.7.0
go: downloading github.com/json-iterator/go v1.1.8
go: downloading github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d
go: downloading github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a
go: downloading github.com/go-openapi/errors v0.19.2
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading go.mongodb.org/mongo-driver v1.1.2
go: downloading golang.org/x/net v0.0.0-20200625001655-4c5254603344
go: downloading github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633
go: downloading github.com/googleapis/gnostic v0.1.0
go: downloading github.com/Azure/go-autorest/autorest v0.9.0
go: downloading github.com/Azure/go-autorest/autorest/adal v0.5.0
go: downloading golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
go: downloading github.com/gophercloud/gophercloud v0.1.0
go: downloading github.com/go-openapi/analysis v0.19.5
go: downloading github.com/go-openapi/loads v0.19.4
go: downloading github.com/go-openapi/runtime v0.19.4
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/Azure/go-autorest/logger v0.1.0
go: downloading github.com/Azure/go-autorest/tracing v0.5.0
go: downloading cloud.google.com/go v0.38.0
go: downloading google.golang.org/appengine v1.5.0
go: downloading github.com/golang/protobuf v1.3.2
go: downloading github.com/Azure/go-autorest/autorest/date v0.1.0
go: downloading github.com/dgrijalva/jwt-go v3.2.0+incompatible
go: downloading golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
go: downloading golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
go: downloading k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89
go: downloading github.com/go-stack/stack v1.8.0
go: downloading golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
go: downloading github.com/dgrijalva/jwt-go v1.0.2
go: downloading github.com/emicklei/go-restful v1.1.3
go get: added sigs.k8s.io/kustomize/kustomize/v3 v3.8.7
operator-sdk generate kustomize manifests -q

Display name for the operator (required): 
> memcached-operator

Description for the operator (required): 
> memcached-operator

Provider's name for the operator (required): 
> memcached-operator

Any relevant URL for the provider name (optional): 
> 

Comma-separated list of keywords for your operator (required): 
> memcached-operator

Comma-separated list of maintainers and their emails (e.g. 'name1:email1, name2:email2') (required): 
> memcached-operator
cd config/manager && /root/go/space/bin/memcached-operator/bin/kustomize edit set image controller=yohaim1511/memcached-operator:v0.0.3
/root/go/space/bin/memcached-operator/bin/kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version 0.0.1  
INFO[0001] Creating bundle.Dockerfile                   
INFO[0001] Creating bundle/metadata/annotations.yaml    
INFO[0001] Bundle metadata generated suceessfully       
operator-sdk bundle validate ./bundle
INFO[0000] All validation tests have completed successfully 
root@philip-virtual-machine:~/go/space/bin/memcached-operator# 
root@philip-virtual-machine:~/go/space/bin/memcached-operator# 
root@philip-virtual-machine:~/go/space/bin/memcached-operator# 
root@philip-virtual-machine:~/go/space/bin/memcached-operator# make bundle-build bundle-push BUNDLE_IMG="yohaim1511/memcached-operator-bundle:v0.0.3"
docker build -f bundle.Dockerfile -t yohaim1511/memcached-operator-bundle:v0.0.3 .
Sending build context to Docker daemon  188.9kB
Step 1/14 : FROM scratch
 ---> 
Step 2/14 : LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
 ---> Running in 72ba73561ed0
Removing intermediate container 72ba73561ed0
 ---> 51f124596d01
Step 3/14 : LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
 ---> Running in a1abdd445933
Removing intermediate container a1abdd445933
 ---> ef21cb9c1883
Step 4/14 : LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
 ---> Running in f0925e3621ce
Removing intermediate container f0925e3621ce
 ---> 2edf330d2b5c
Step 5/14 : LABEL operators.operatorframework.io.bundle.package.v1=memcached-operator
 ---> Running in 807caa49d75a
Removing intermediate container 807caa49d75a
 ---> 98d7477f9c18
Step 6/14 : LABEL operators.operatorframework.io.bundle.channels.v1=alpha
 ---> Running in 81ac44ab48a4
Removing intermediate container 81ac44ab48a4
 ---> e229ec057dea
Step 7/14 : LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.15.0+git
 ---> Running in 21b978502e1e
Removing intermediate container 21b978502e1e
 ---> 2c4c804ef034
Step 8/14 : LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
 ---> Running in 06c89c16f224
Removing intermediate container 06c89c16f224
 ---> 8f48e4faa05a
Step 9/14 : LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
 ---> Running in c4d4814bfae6
Removing intermediate container c4d4814bfae6
 ---> 4d4e7f934b9b
Step 10/14 : LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
 ---> Running in 36839d0a92cb
Removing intermediate container 36839d0a92cb
 ---> f6f846b3de0f
Step 11/14 : LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
 ---> Running in e3fc3d56907d
Removing intermediate container e3fc3d56907d
 ---> 700e50fa81d6
Step 12/14 : COPY bundle/manifests /manifests/
 ---> 8a6b0b33f0dc
Step 13/14 : COPY bundle/metadata /metadata/
 ---> 4c5e53996058
Step 14/14 : COPY bundle/tests/scorecard /tests/scorecard/
 ---> ea083fe3c9a6
Successfully built ea083fe3c9a6
Successfully tagged yohaim1511/memcached-operator-bundle:v0.0.3
make docker-push IMG=yohaim1511/memcached-operator-bundle:v0.0.3
make[1]: 디렉터리 '/root/go/space/bin/memcached-operator' 들어감
docker push yohaim1511/memcached-operator-bundle:v0.0.3
The push refers to repository [docker.io/yohaim1511/memcached-operator-bundle]
5ce7d5b63abd: Pushed 
b35f56f2cc7d: Pushed 
8e58b1568366: Pushed 
v0.0.3: digest: sha256:3cf2e4b7b5605d4b87357357e569f58bad1028bdb96b4f5e97b87b9fc6be0341 size: 939
make[1]: 디렉터리 '/root/go/space/bin/memcached-operator' 나감
root@philip-virtual-machine:~/go/space/bin/memcached-operator#

번들을 실행

root@philip-virtual-machine:~/go/space/bin/memcached-operator# operator-sdk run bundle docker.io/yohaim1511/memcached-operator-bundle:v0.0.3
INFO[0025] Successfully created registry pod: docker-io-yohaim1511-memcached-operator-bundle-v0-0-3 
INFO[0025] Created CatalogSource: memcached-operator-catalog 
INFO[0025] OperatorGroup "operator-sdk-og" created      
INFO[0025] Created Subscription: memcached-operator-v0-0-1-sub 
INFO[0033] Approved InstallPlan install-44bdq for the Subscription: memcached-operator-v0-0-1-sub 
INFO[0033] Waiting for ClusterServiceVersion "default/memcached-operator.v0.0.1" to reach 'Succeeded' phase 
INFO[0033]   Waiting for ClusterServiceVersion "default/memcached-operator.v0.0.1" to appear 
INFO[0056]   Found ClusterServiceVersion "default/memcached-operator.v0.0.1" phase: Pending 
INFO[0058]   Found ClusterServiceVersion "default/memcached-operator.v0.0.1" phase: InstallReady 
INFO[0059]   Found ClusterServiceVersion "default/memcached-operator.v0.0.1" phase: Installing 
INFO[0079]   Found ClusterServiceVersion "default/memcached-operator.v0.0.1" phase: Succeeded 
INFO[0079] OLM has successfully installed "memcached-operator.v0.0.1" 
root@philip-virtual-machine:~/go/space/bin/memcached-operator#

파드를 확인

root@philip-virtual-machine:~/go/space/bin/memcached-operator# kubectl get pods
NAME                                                              READY   STATUS      RESTARTS   AGE
ca100765797d18509ae2e7149c95780ad9b17d8517bc2164bf19bc01de2lczp   0/1     Completed   0          8m34s
docker-io-yohaim1511-memcached-operator-bundle-v0-0-3             1/1     Running     0          8m56s
memcached-operator-controller-manager-848dfcd985-gj4sc            2/2     Running     0          8m9s
root@philip-virtual-machine:~/go/space/bin/memcached-operator#

 

자동 생성된 쿠버네티스 CRD 확인

root@philip-virtual-machine:~/go/space/bin/memcached-operator# ll
합계 160
drwxr-xr-x 10 root root  4096  1월 12 17:30 ./
drwxr-xr-x  4 root root  4096  1월 12 17:19 ../
-rw-------  1 root root   129  1월 12 17:21 .dockerignore
-rw-------  1 root root   367  1월 12 17:21 .gitignore
-rw-------  1 root root   776  1월 12 17:21 Dockerfile
-rw-------  1 root root  9455  1월 12 17:21 Makefile
-rw-------  1 root root   448  1월 12 17:21 PROJECT
drwx------  3 root root  4096  1월 12 17:21 api/
drwxr-xr-x  2 root root  4096  1월 12 17:29 bin/
drwxr-xr-x  5 root root  4096  1월 12 17:30 bundle/
drwx------  2 root root  4096  1월 12 17:27 bundle-748974932/
drwx------  2 root root  4096  1월 12 17:22 bundle-861863922/
-rw-r--r--  1 root root   923  1월 12 17:30 bundle.Dockerfile
drwx------ 10 root root  4096  1월 12 17:21 config/
drwx------  2 root root  4096  1월 12 17:21 controllers/
-rw-r--r--  1 root root   189  1월 12 17:24 cover.out
-rw-------  1 root root   226  1월 12 17:21 go.mod
-rw-r--r--  1 root root 77000  1월 12 17:21 go.sum
drwx------  2 root root  4096  1월 12 17:21 hack/
-rw-------  1 root root  3192  1월 12 17:21 main.go
root@philip-virtual-machine:~/go/space/bin/memcached-operator# cd config
root@philip-virtual-machine:~/go/space/bin/memcached-operator/config# ll
합계 40
drwx------ 10 root root 4096  1월 12 17:21 ./
drwxr-xr-x 10 root root 4096  1월 12 17:30 ../
drwx------  4 root root 4096  1월 12 17:23 crd/
drwx------  2 root root 4096  1월 12 17:21 default/
drwx------  2 root root 4096  1월 12 17:21 manager/
drwxr-xr-x  3 root root 4096  1월 12 17:30 manifests/
drwx------  2 root root 4096  1월 12 17:21 prometheus/
drwx------  2 root root 4096  1월 12 17:23 rbac/
drwx------  2 root root 4096  1월 12 17:21 samples/
drwxr-xr-x  4 root root 4096  1월 12 17:21 scorecard/
root@philip-virtual-machine:~/go/space/bin/memcached-operator/config# cd samples
root@philip-virtual-machine:~/go/space/bin/memcached-operator/config/samples# ll
합계 16
drwx------  2 root root 4096  1월 12 17:21 ./
drwx------ 10 root root 4096  1월 12 17:21 ../
-rw-------  1 root root  128  1월 12 17:21 cache_v1alpha1_memcached.yaml
-rw-r--r--  1 root root  160  1월 12 17:21 kustomization.yaml
root@philip-virtual-machine:~/go/space/bin/memcached-operator/config/samples# pwd
/root/go/space/bin/memcached-operator/config/samples