---
# System prepended metadata

title: III Job Transfer
tags: [DevOps, CI/CD, III]

---

III Job Transfer
===

###### tags: `III` `DevOps` `CI/CD`

### [運維工作] 每週清除 container和 image
**[注意] CREATED TIME超過七天以上才能刪!**
1. 分別登入 10.22.100.233 和 10.22.100.231
2. 刪除以下 container
* ```nelson-vmme-xxx-check_exe```
* ```nelson-vmme-xxx-unit_test```
* ```abby-vmme-xxx-check_exe```
* ```abby-vmme-xxx-unit_test```
```
sudo docker ps -a
sudo docker stop <CONTAINER>
sudo docker rm <CONTAINER>
```
3. 刪除以下 image
* ```docker5gc:5000/nelson-vmme:xxx```
* ```docker5gc:5000/abby-vmme:xxx```
```
sudo docker images
sudo docker rmi <IMAGE>
```
4. 檢查 http://docker5gc:8080
* ```nelson-vmme```
* ```abby-vmme```
```
sudo ./clean_up.sh image -s docker5gc:5000 -r <IMAGE> -t <TAG>
```
備註: vMME/docker/clean_up.sh

### docker5gc:8080 上的 images
| Repository | Tag | Definition | Generated from |
| -------- | -------- | -------- | -------- |
|  5gc   | v1.0.0 (```git show v1.0.0```可反查commit-SHA) | 已刪除 source code，關閉```-D_NO_CIPHER```及```-D_SMF_TEST_PAGING```，開啟```-D_CHANGE_GUTI```![](https://i.imgur.com/W5eWd4q.png) | ![](https://i.imgur.com/nl3DXfe.png) docker/Dockerfile_release |
|  nelson  | 1234 (pipeline ID) | 測試用途，跑完 pipeline 會自動刪除 | ![](https://i.imgur.com/KrjUNU4.png) docker/Dockerfile_all |
|  nelson  | a1234567 (commit-SHA) | 手動觸發，無刪除任何 source code | ![](https://i.imgur.com/swXJ76H.png) docker/Dockerfile_all | 
| deployenv | a1234567 (commit-SHA) | pipeline 某個 job 會用到的 image | http://gitvepc/5gc/deployenv |
| deployenv-dind | a1234567 (commit-SHA) | pipeline 某個 job 會用到的 image | http://gitvepc/5gc/deployenv |
| buildenv | a1234567 (commit-SHA) | nelson 及 5gc 的 based image | http://gitvepc/5gc/buildenv |

### 所有 VMs
| IP | User | Pass | Usage |
| -------- | -------- | -------- | -------- |
| 10.22.100.233 | vm10 | vm10 | K8s 的 master node 用來放 GitLab Runner。 |
| 10.22.100.231 | vm10 | vm10 | K8s 的 woker node 用來放 GitLab Runner。 |
| 10.22.124.10 | xk8s | xk8s | 這是 xk8s。 GitLab pipeline 的 deploy stage 手動觸發時用來佈署產品的平台。 |
| 10.22.100.108 | iii | iii123@ | Private Docker Hub Server。http://docker5gc:5000 (沒有 Web GUI) 和 http://docker5gc:8080 。 |
| 10.22.100.251 | vm251 | vm251  | Code Coverage Server。http://codecov5gc:8080/ 。 |

### 所有 Repositories
| Project | Usage |
| -------- | -------- |
| http://gitvepc/nelson/vMME | 5GC開發專案 |
| http://gitvepc/abby/vMME | 5GC開發專案-練習用途 |
| http://gitvepc/5gc/buildenv | 5GC based image (**docker/Dockerfile_all** 和 **docker/Dockerfile_release** 的 based image)  |
| http://gitvepc/5gc/deployenv | GitLab pipeline 一些 job 的 image，裝有一些命令工具 |
| http://gitvepc/abby/gitlab-runner | GitLab Runner |

### 觸發 pipeline 的設定檔是 .gitlab-ci.yml
* [如何寫 .gitlab-ci.yml](https://docs.gitlab.com/ee/ci/yaml/)
* [```CI_```開頭變數的定義](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)

### 透過 branch 觸發 pipeline
![](https://i.imgur.com/yC67XaQ.png)
```
git clone http://gitvepc/abby/vMME.git
cd vMME/
git branch
git checkout -b NEW_LOCAL_BRANCH
git branch
vim test.yaml
git status
ls .git
git add test.yaml
git status
vim README.md
git status
git commit -m 'Fix xxx bug'
git log
git remote -v
git push origin NEW_LOCAL_BRANCH:NEW_REMOTE_BRANCH
git remote -v
git branch
git log
```

### 透過 tag 觸發 pipeline
![](https://i.imgur.com/Fp6dFWk.png)
```
git tag v3.0.0
git tag --list
git show v3.0.0
git push origin v3.0.0
```

### 其他參考筆記
- [GitLab CI/CD 分享給其他開發者的筆記](https://hackmd.io/@derailment/iii-cicd-tutorial)
- [GitLab CI/CD](https://hackmd.io/@derailment/gitlab-cicd)
- [GitLab Runner](https://hackmd.io/@derailment/gitlab-runner)
- [Private Docker Hub](https://hackmd.io/@derailment/docker-registry)
- [DNS Trouble Shooting](https://hackmd.io/@derailment/troubleshooting)
- [K8s Remote Access](https://hackmd.io/@derailment/k8s-access)
- [K8s Scale Out](https://hackmd.io/@derailment/k8s-scale)
- [Code Coverage Tools: g++ flags and gcovr](https://hackmd.io/@derailment/code-coverage)
- [Code Coverage Server: nginx](https://hackmd.io/@derailment/nginx)