Our goal is simple: It is just to create K8s with GKE, create a Jenkins deployment and services then connect the two.
Technology: Kubernetes, Google Cloud Kubernetes, Jenkins, Helms, GitHub
Follow the below steps after verifying your user through the Google cloud console.
Step 1: Create the Kubernetes cluster on the Kubernetes engine using the command below on the gcloud environment.
gcloud container clusters create jenkins-cd \
--num-nodes 2 \
--scopes "https://www.googleapis.com/auth/projecthosting,cloud-platform"
The command specified the cluster name and the scope to access the Jenkins access to the necessary artifacts.
After the command successfully completed, run the command gcloud container clusters list
to see the output that look like below that contain the information about the newly created cluster.
b. Let's find out the credential of the cluster by running the command
gcloud container clusters get-credentials jenkins-cd
c. Confirm the connection with the command
kubectl cluster-info
Output:
Step 2: Helm Installation and Configuration
- what is helm? Helm is a package manager that makes it easy to configure and deploy Kubernetes applications. a. After successful installation of Helm from helm documentation guide. The next is adding the Jenkins chart repo with the command
helm repo add jenkins https://charts.jenkins.io
For every installation, it is advisable to update to newer version. this can be done by running.
helm repo update
b. Let's run helm package manager against the yaml configuration files that can be found in this repository under the Jenkins folder. Execute the below command against the config files. The values config file add the Google Cloud specific plugin necessary to use service account credentials to reach Source Repository
helm upgrade --install -f jenkins/values.yaml myjenkins jenkins/jenkins
c. Display the running pods with the command
kubectl get pods
d. Let's port forward the Jenkins UI from the cloud shell with the command
echo http://127.0.0.1:8080
kubectl --namespace default port-forward svc/myjenkins 8080:8080 >> /dev/null &
Step 3: Connecting the Jenkins
a. Access the Jenkins UI admin login credentials with the command.
kubectl exec --namespace default -it svc/myjenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo
And the deployed Jenkins running will produce a page like this.
Top comments (0)