Gitlab CI + Kubernetes 关于 CI/CD 的一个示例。在博客中有几篇文章专门来介绍关于 Gitlab CI 的:
- 1. 在 Kubernetes 在快速安装 Harbor
- 2. 在 Kubernetes 上安装 Gitlab
- 3. 在 Kubernetes 上安装 Gitlab CI Runner
- 4. Gitlab CI 与 Kubernetes 的结合
This repository shows off/uses the following GitLab CI features:
Other features also shown are:
- coreos/prometheus-operator ServiceMonitor - for automatic monitoring of deployed applications.
The following points are required for this repository to work correctly:
- GitLab (
>= 11.3
) with the following features configured:- Harbor
- GitLab CI (with working GitLab CI Runners, at least version
>= 11.3
)
- Kubernetes cluster
- You need to be "bound" to the
admin
(cluster-admin
) ClusterRole, see Kubernetes.io Using RBAC Authorization - User-facing Roles. - An Ingress controller should already been deployed, see Kubernetes.io Ingress.
- You need to be "bound" to the
kubectl
installed locally.- Editor of your choice.
- GitLab Kubernetes Integration Docs: https://docs.gitlab.com/ce/user/project/integrations/kubernetes.html
- GitLab Kubernetes Integration Docs Environment variables: https://docs.gitlab.com/ce/user/project/integrations/kubernetes.html#deployment-variables
main.go
- The Golang example application code.vendor/
- Contains the Golang example application dependencies (dep
is used).Gopkg.lock
andGopkg.toml
- Golangdep
.
Dockerfile
- Contains the Docker image build instructions..gitlab-ci.yml
- Contains the GitLab CI instructions.
manifests/
- Kubernetes manifests used to deploy the Docker image built in the CI pipeline.deployment.yaml
- Deployment for the Docker image.ingress.yaml
- Ingress for the application.service.yaml
- Service for the application.
Thanks to @shadycuz - GitHub for his comments with improvements for the code in this repository!
The files in this repo can be used under the MIT license, see LICENSE file.