Open GunSik2 opened 2 years ago
curl -L "https://github.com/weaveworks/weave-gitops/releases/download/v0.3.0/gitops-$(uname)-$(uname -m)" -o gitops
chmod +x gitops
sudo mv ./gitops /usr/local/bin/gitops
gitops version
$ gitops install
$ kubectl get pods --namespace wego-system
NAME READY STATUS RESTARTS AGE
helm-controller-b5c45677f-zz6r7 1/1 Running 0 80s
image-automation-controller-57f8bf65c7-km8qn 1/1 Running 0 80s
image-reflector-controller-558c56b989-nnsbw 1/1 Running 0 80s
kustomize-controller-7fd4d6b4c8-jwbks 1/1 Running 0 80s
notification-controller-66545867f4-bsmqk 1/1 Running 0 80s
source-controller-5d469c75b6-vtjqf 1/1 Running 0 80s
GitHub에서 예시용 레퍼지토리 Fork
$ git clone https://github.com/GunSik2/podinfo-deploy
$ cd podinfo-deploy/
$ ◎ Checking cluster status
✔ GitOps installed
⚠️ Setting the "GITHUB_TOKEN" environment variable to a valid token will allow ongoing use of the CLI without requiring a browser-based auth flow...
Visit this URL to authenticate with Github:
https://github.com/login/device
Type the following code into the page at the URL above: 735C-2CC2
Waiting for authentication flow completion...
Authentication successful!
Existing deploy key found Adding application:
Name: podinfo-deploy URL: ssh://git@github.com/GunSik2/podinfo-deploy.git Path: ./ Branch: main Type: kustomize
✚ Generating Source manifest ✚ Generating GitOps automation manifests ✚ Generating Application spec manifest ► Cloning ssh://git@github.com/GunSik2/podinfo-deploy.git Pull Request created: https://github.com/GunSik2/podinfo-deploy/pull/1
► Applying manifests to the cluster ► Committing and pushing gitops updates for application ✔ App is up to date
2. 중간에 Github 접속하여 인증 필요: https://github.com/login/device
![image](https://user-images.githubusercontent.com/11453229/135553089-0efe2f85-e9c1-4edb-86c3-90830e5c3c1a.png)
3. GitOps Pull Request 확인
![image](https://user-images.githubusercontent.com/11453229/135554836-bbf87246-f98a-414a-8474-145f5fd83641.png)
4. GitOps Pull Request 승인
![image](https://user-images.githubusercontent.com/11453229/135554890-220cc691-3dae-4b62-b497-535f0b46eef8.png)
5. App 배포 확인
$ kubectl get pod -n test NAME READY STATUS RESTARTS AGE backend-6597979bbf-njhtr 1/1 Running 0 2m frontend-745f795d57-dgbwx 1/1 Running 0 2m
$ gitops app status podinfo-deploy NAME READY MESSAGE REVISION SUSPENDED gitrepository/podinfo-deploy True Fetched revision: main/dfd72488c9be9ee52fd0726ba7e118dd7d84e48d main/dfd72488c9be9ee52fd0726ba7e118dd7d84e48d False
NAME READY MESSAGE REVISION SUSPENDED kustomization/podinfo-deploy True Applied revision: main/dfd72488c9be9ee52fd0726ba7e118dd7d84e48d main/dfd72488c9be9ee52fd0726ba7e118dd7d84e48d False
// 초기 배포 시 자동 생성된 파일 $ git pull $ tree .wego/ .wego/ ├── apps │ └── podinfo-deploy │ └── app.yaml └── targets └── local └── podinfo-deploy ├── podinfo-deploy-gitops-deploy.yaml └── podinfo-deploy-gitops-source.yaml
apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: podinfo namespace: test spec: rules:
7. 앱 접속 확인
![image](https://user-images.githubusercontent.com/11453229/135608506-bea75137-8bb9-45f4-9f67-c9675520ae16.png)
$ vi frontend/deployment.yaml
env:
- name: PODINFO_UI_COLOR
value: "#888888"
$ git add .
$ git commit -m "change color"
$ git push
// 자동 배포 확인 $ kubectl get pods --namespace test NAME READY STATUS RESTARTS AGE backend-6597979bbf-njhtr 1/1 Running 0 8h frontend-5557476b4-t6pbp 1/1 Running 0 95s
8. 앱 업데이트 확인
![image](https://user-images.githubusercontent.com/11453229/135608423-bf5175d3-54fe-4e0d-bc5a-74f750f4b0a0.png)
참고
- https://docs.gitops.weave.works/docs/getting-started/
- https://github.com/weaveworks/weave-gitops
► Cloning ssh://git@github.com/GunSik2/podinfo-deploy.git
Error: failed to add the app : failed to clone application repo: failed cloning user repo: ssh://git@github.com/GunSik2/podinfo-deploy.git: ssh: handshake failed: knownhosts: key is unknown
$ git clone git@github.com:GunSik2/podinfo-deploy.git
Cloning into 'podinfo-deploy'...
The authenticity of host 'github.com (52.78.231.108)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
$ kubectl create ingress frontend --rule="podinfo.14.xx.xxx.xxx.xip.io/*=frontend:9898" -n test
error: failed to create ingress: the server could not find the requested resource
// 버전 차이 확인
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:45:37Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"1f3e19b7beb1cc0110255668c4238ed63dadb7ad", GitTreeState:"clean", BuildDate:"2021-06-16T12:51:17Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.22) and server (1.18) exceeds the supported minor version skew of +/-1
// kubectl 재설치 $ curl -LO https://dl.k8s.io/release/v1.18.0/bin/linux/amd64/kubectl $ chmod +x kubectl $ sudo mv kubectl /usr/local/bin/kubectl
// 버전 확인 $ kubectl version Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.20", GitCommit:"1f3e19b7beb1cc0110255668c4238ed63dadb7ad", GitTreeState:"clean", BuildDate:"2021-06-16T12:51:17Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
GitOps 개발자 환경
참고
GitOps
GitOps 개발자 환경
참고자료