From gitlab to kubernetes

  1. In gitlab, create a gitlab-ci.yml file. If using GCR, login to GCR with the GCP service account key. See GCR documentation.
echo $GCP_SERVICE_KEY | base64 -d | docker login -u _json_key  --password-stdin https://${GCR}
docker build -t ${IMAGE_NAME} .docker tag $IMAGE_NAME “${GCR}/${GCP_PROJECT}/${IMAGE_NAME}”docker push “${GCR}/${GCP_PROJECT}/${IMAGE_NAME}:latest”
## select the project
$ gcloud config set project <project_name>
## show the k8s context and cluster info
kubectl config current-context
## show the k8s cluster list
$ gcloud container clusters list
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
k8s-dev us-east1 1.20.12-gke.1500 10.10.22.6 e2-medium 1.19.15-gke.1801 * 5 RUNNING
<helm_chart_folder>
- templates
|- configmap.yaml
|- deployment.yaml
- Chart.yaml
- values.yaml
## helm install <release_name> <folder_name> -n <namespace>
$ helm install <name> . -n <namespace>
## to get the pod name
$ kubectl -n <namespace> get pods
$ kubectl -n <namespace> describe pod <podname>Name: mycompo-7bfd77747-wrzv8
Namespace: namespace
Priority: 0
Node: gke-k8s-dev-default-node-pool-15936747–3m17/10.60.40.49
Start Time: Sat, 12 Jan 2021 10:02:42 +0800
Labels: component=mycompo
pod-template-hash=5afd77747
Annotations: cni.projectcalico.org/podIP: 10.10.48.130/32
cni.projectcalico.org/podIPs: 10.10.48.130/32
rollme: rgjQT
Status: Running
IP: 10.10.48.130
IPs:
IP: 10.10.48.130
Controlled By: ReplicaSet/mycompo-5afd77747
Containers:
mycompo:
Container ID: docker://ff9dd6474fee5de07fb974d30bf4f410b49b673124cade14925daf2742d9e06a35

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store