Image to deploy with gitlab in kubernetes
10K+
A docker image to build docker image and deploy in kubernetes with gitlab.
Notes : since tools-gitlab-auto-deploy-image v2.0, helm 3 is required.
kubernetes
kube_setup
Setup a kubernetes environment
kubectl is set from KUBECONFIG (gitlab autoset it) or with KUBECONFIG_URLKUBE_NAMESPACE environment variable (if not in gitlab managed cluster)kubectl default namespace is set to KUBE_NAMESPACEhelm is initialized with a tiller service is the current namespacegitlab-registry using gitlab ci default variables or named from env K8S_IMAGE_PULL_SECRET_REGISTRY using EXTERNAL_REGISTRY* env.kube_cleanup
delete a kubernetes environment
helm release installation in the current namespacetiller installation in the current namespacekube_get_pods
get pods name from a selector in argumentdocker
docker_build
build, tag and push an image according CI_COMMIT_REF_SLUGdocker_tag_latest
tag and push image according CI_COMMIT_REF_SLUG to latestdocker_digest_tag
pull an image and return full image tag with digest in order to pin image across deploymentdocker_gitlab_login
log to gitlab registry using CI_REGISTRY_*docker_external_login
log to an external registry using
EXTERNAL_REGISTRY for registry host or host + namespace, (by default to index.docker.io)EXTERNAL_REGISTRY_LOGIN for loginEXTERNAL_REGISTRY_PASSWORD for passworddocker_push_gitlab_to_external
pull docker image from gitlab registry and push it to an external registry (by default to index.docker.io)
first parameter
This Docker image from Gitlab ex: docker-registry.example.com/organization/repository:tagsecond parameter
This Docker image to push to the external registry ex: organization/repository:tag or rg.fr-par.scw.cloud/namespace/repository:tagdocker_login DEPRECATED use: docker_external_login
log to docker registrydocker_push_gitlab_to_dockerhub DEPRECATED use: docker_external_login
pull docker image from gitlab registry and push it to dockerhub
first parameter
This Docker image from Gitlab ex: docker-registry.example.com/organization/repository:tagsecond parameter
This Docker image to push to dockerhub ex: organization/repository:tagcheck_version : show docker, kubectl and helm versions
notify_deployment : notify deployment to grafana monitoring service
Just add the following lines to your .gitlab-ci.yml :
image: vikyai/tools-gitlab-auto-deploy-image:latest
before_script:
- . /auto-deploy.sh
Example :
stages:
- build
- deploy
image: vikyai/tools-gitlab-auto-deploy-image:latest
before_script:
- . /auto-deploy.sh
build:
stage: build
script:
- docker_build ${CI_REGISTRY_IMAGE}
- docker_tag_latest ${CI_REGISTRY_IMAGE}
kube:
stage: deploy
environment:
name: ${CI_COMMIT_REF_NAME}
script:
- kube_setup
- helm upgrade --wait --install "${RELEASE_NAME}" stable/redis
cleanup:
stage: deploy
environment:
name: ${CI_COMMIT_REF_NAME}
action: stop
variables:
GIT_STRATEGY: none
script:
- kube_setup
- kube_cleanup
when: manual
allow_failure: true
Content type
Image
Digest
Size
111.8 MB
Last updated
almost 6 years ago
docker pull vikyai/tools-gitlab-auto-deploy-image