This workshop is presented by VMware and Cloudbees
Instructions created by Dan Illson and Jeff Fry
Presented by Valentina Alaria, Jeff Fry, Dan Illson, Sean O'Dell, and Bill Shetti
In order to successfully complete this workshop, you will need:
- A terminal shell (preferably bash) or emulator
- A github account
- A Dockerhub account
- The git command line package configured within the shell
- The kubectl utility installed (this can be installed from the VKE UI)
- Helm installed
- A login for the VMware Kubernetes Engine service (provided at check-in)
If you need to install any of the prerequsites or signup for a github account, this can be done while the VMware Kubernetes Engine cluster is being built or the Cloudbees core components/Jenkins master are being provisioned.
Please follow the links above for instructions to install or request the prerequisite items.
Download the CLI package from the button in the bottom left corner of the screen labeled 'Download CLI' and select the correct operating system. Make sure it has execute permissions.
Use the following format, replacing organization-id with your organization ID and refresh-token with your refresh token.
vke account login -t organization-id -r refresh-token
The organization ID is available in the VKE UI by clicking on the box showing your username and organization name in the upper right portion of the screen. Please click on the Org ID to get the long form and use that long form in the command.
For an API/refresh token, please click again on the box displaying your username and organization name. Then please click on the 'My Account' button.
On the resulting page, please select 'API tokens' the third option in the horizontal navigation bar under 'My Account'. If you have an existing token, please copy and use it, otherwise please click the button labelled 'New Token' and then copy the result.
Copy these values down to a text file, they will be important during Jenkins configuration later.
To create a VKE cluster, run the following command:
vke cluster create --name <cluster name> --region us-west-2 -f sharedfolder -pr sharedproject --privilegedMode
For region please use the value 'us-west-2'
You will be asked to acknowledge the creation of a piviliged mode Kubernetes cluster. Please enter 'Y' at the prompt.
If it isn't already installed on your machine, please install the kubectl command line package for managing Kubernetes.
Kubectl can be pulled down in a variety of ways, including from the VKE UI (on the page for a smartcluster, select actions and then select the correct operating system for your device).
For Helm, please see the following page: Helm
To gain kubectl access to your VKE cluster via the command line use the following command:
vke cluster merge-kubectl-auth <cluster name>
This will authenticate kubectl to your VKE cluster and set the correct context to access that cluster.
Correct funtionality can be verfied by successfully running 'kubectl get' commands against the cluster (kubectl get nodes, kubectl get pods, etc)
To setup Tiller (the cluster side component of Helm) in your VKE cluster, run the following command:
helm init
helm repo update
The 'helm repo update' command pulls the most recent version of the charts in any repositiories mapped into Helm (stable by default) so as to avoid installing older versions of these components, which might introduce issues.
The helm init
command will take a couple of minutes to run on the VKE cluster as it will cause the cluster to scale up and add a worker node.
This is expected, please move on to the
In order to feed the CI/CD pipeline automatically on a git push, you'll need to create an individual copy of this repository.
In order to have your own working copy of this repository, you'll want to fork it into your account.
- First navigate to [http://github.com] and login to your account
- Then navigate to the page for this repository [https://github.com/dillson/jw-workshop]
- In the upper-right hand section of the screen, click on the button labeled 'Fork'
A copy of this repository will then be forked into your account
First pick a location on your local machine to clone the forked repository.
After ensuring that 'git' is installed, run these commands:
cd jw-workshop
git clone https://github.com/<your username>/jw-workshop.git
Comgratulations, you know have a local copy of this repository. It will be in a folder labeled 'jw-workshop'
From the cloned repo root folder, run the following command:
sed -i 's/dillson/<your dockerhub username>/g' deployFiles/deployment.yaml
This will alter the deployment file to use the comtainer image from your personal repository rather than from mine. This will be important while iterating on the express code later.
From the cloned repo root folder, run the following commands:
sed -i 's/dillson/<your dockerhub username>/g' Jenkinsfile
sed -i 's/cb-test-59/<your cluster name>/g' Jenkinsfile
The cluster name is whatever you named your VKE cluster during the VKE cluster provisioning steps previously.
Now run:
git add Jenkinsfile
git commit -m 'altered Jenkinsfile for my parameters'
git push -u origin master
These commands add, commit, and push these changes to your online repository for the pipeline to read later.
Stay in this folder for the next steps
Helm Chart for CloudBees Core on VMware Kubernetes Engine (VKE) - based on This repo by Jeff Fry
From folder 'jw-workshop' (root of the cloned repository), run:
helm package core-helm-vke/CloudBeesCore
- Install Helm if not already installed.
helm init
- Wait for the tiller pod to come up. This may take a few minutes.
kubectl -n kube-system get pods
NAME READY STATUS RESTARTS AGE
tiller-deploy-5c688d5f9b-l27kk 1/1 Running 0 3m
- Create a namespace for CloudBees Core to be installed in.
kubectl create namespace cloudbees
- Install an Nginx Ingress Controller with Helm. Ensure you specify the controller scope using the cloudbees namespace
kubectl create namespace ingress-nginx
kubectl create clusterrolebinding nginx-ingress-cluster-rule --clusterrole=cluster-admin --serviceaccount=ingress-nginx:nginx-ingress
helm install --namespace ingress-nginx --name nginx-ingress stable/nginx-ingress --version 0.23.0 --set rbac.create=true --set controller.service.externalTrafficPolicy=Local --set controller.scope.enabled=true --set controller.scope.namespace=cloudbees
- Wait for the Load Balancer Ingress field to populate. This is the hostname that will be used in the next step. This may take a few minutes and require multiple runs before the value populates.
kubectl describe service nginx-ingress-controller -n ingress-nginx
- Install CloudBees Core. The value is included in the output of the previous command.
helm install core-helm-vke/cloudbeescore --set cjocHost=<lb-ingress-hostname> --namespace cloudbees
- Monitor the progress.
kubectl rollout status sts cjoc --namespace cloudbees
- Wait for success message.
statefulset rolling update complete 1 pods at revision cjoc-59cc694b8b...
- Go to
http://<lb-ingress-hostname>/cjoc
- Get the initial admin password.
kubectl exec cjoc-0 cat /var/jenkins_home/secrets/initialAdminPassword --namespace cloudbees
- Follow the instructions in the setup wizard. Request a trial license. Select the 'Install selected plugins' option.
- If prompted for an 'Operations Center Upgrade', please ignore and continue without it.
- Click on the Teams menu item.
- Follow the team creation wizard.
- Specify a name for team.
- Choose an icon.
- Select the 'Basic' team recipe.
- Wait for a few minutes for the Jenkins Master to be created.
- Use the button just to the left of the 'Logout' button that looks like an exit sign to reach the classic Jenkins UI. The alt-text for this button is 'Go to classic.'
- Use the horizontal navigation bar at the top of the screen to navigate to the leftmost 'Jenkins'
- From the vertical navigation bar on the left edge of the screen, select 'Manage Jenkins' -> 'Manage Plugins'
- Select the 'Available' tab from the top of the main panel. Then search down the list for 'GitHub plugin'. Check the box for this plugin, then click the 'Install without restart' button at the bottom of the screen
Return to the main screen of the Cloudbees Jenkins Operations Center by using the horizontal navigation bar at the top of the screen again. Click on the leftmost entry 'Jenkins'
- Click on the 'Teams >> {name}' link in the middle of the main panel. The name will be the value you specified when creating a team earlier.
- Select 'Credentials' from the vertical navigation bar on the left edge of the screen
- Look for the section labeled 'Stores scoped to Jenkins'
- Under that section, click on the link for the (global) domain
- From the vertical nav bar on the left edge of the screen, click 'Add Credentials'
- Select 'Username with password' from the 'Kind' dropdown menu at the top of the screen.
- Leave 'Scope' set to Global
- In the Username field, enter your dockerhub user name. In Password, enter your dockerhub password. For ID and description, you must use 'dockerhub'
- Click 'OK'
- Click 'Add Credentials' from the vertical navigation bar again.
- Use 'Username with password' from the 'Kind' dropdown menu. Use 'Global' as the scope.
- For username, use your VKE orgnaization ID from the cluster provisioning stage.
- For password, use your VKE API/refresh token noted down during VKE cli login.
- For ID, you must use 'VCS'. Add a relevant description for your reference.
- Click 'OK'
Return to the main screen of the Cloudbees Jenkins Operations Center by using the horizontal navigation bar at the top of the screen again. Click on the leftmost entry 'Jenkins'
- Click on the 'Teams >> {name}' link in the middle of the main panel. The name will be the value you specified when creating a team earlier.
- From the vertical navigation bar on the left edge of the screen, click 'New Item'
- Select the 'Pipeline' type from the list. Be sure to give it a name. Then click the 'OK' button at the bottom of the screen.
- On the following screen, Check the box in the 'General' section reading 'GitHub Project'. A text box will then appear and ask for the project URL. Use the URL of your forked Github repository. Likely of the form, "github.com/'username'/jw-workshop".
- Under the 'Build Triggers' section, check the box labeled 'GitHub hook trigger for GITScm polling'. This will enable the desired 'build on git push' behavior.
- In the 'Pipeline' section, location the 'Definition' dropdown menu. In that dropdown, select 'Pipeline script from SCM'
- From the 'SCM' sub dropdown menu, select 'Git'
- In the 'Repositor URL' text field, enter the URL of your forked repository.
- Ensure the 'Credentials' dropdown menu value is '- none -'.
- Locate the 'Script Path' text field menu and enter 'Jenkinsfile'
- Click 'Apply', the 'Save' at the bottom of the screen.
From the Pipeline status screen (reached by navigating to your pipeline and using the vertical nav bar at the left). Once here, click the 'Build Now' link in the vertical nav bar on the left edge of the screen to execute the pipeline once on-demand.
- On your local machine, run :
vke cluster show <cluster name>
. - Look for the 'Address:' line, then copy the URL displayed on that line.
- In your browser, navigate to
http://<address value>:30400
- You should be on the root web page of an express (node.js) app welcoming you to the workshop. There are also 2 subpages:
- /vke
- /cloudbees
This section represents extended activities for those who complete the base workshop. The section fully automates the CI/CD pipeline to trigger off of a push event to the git repository.
Return to the main screen of the Cloudbees Jenkins Operations Center by using the horizontal navigation bar at the top of the screen again. Click on the leftmost entry 'Jenkins'
- From the vertical navigation bar on the left edge of the screen, select 'Manage Jenkins' -> 'Configure System'
- Scroll down until you come to the 'Github' section of the conifg
- Click the button for 'Add GitHub Server'
- The API URL text field should read,
https://api.github.com
. If not, please edit it to that value - Ensure that the 'Manage Hooks' box is checked.
- Locate the bottommost 'Advanced' button in the GitHub section.
- In the 'Additional Actions' sub section, click the 'Manage additional GitHub actions' dropdown and the 'Convert login and password to token' option
- Select the radio button for 'From login and password'
- Enter your Github username and password, then click the 'Create token credentials' button.
- Click the 'Apply' button at the bottom of the screen.
- Under the 'API URL' text field at the top of the GitHub section, there is a credentials dropdown. Select the credential you just created. It will start with
Github (https://api.github.com) auto generated token credentials
. - Click the 'Apply' button at the bottom of the screen.
- In the 'Shared Secret' dropdown menu, select the same option as 'Credentials' dropdown above.
- Click the 'Apply' button at the bottom of the screen. Then click the 'Save' button.
- Alter the app code. Pick from the set of
*.hbs
files in the views/ folder of the repository. - Save the changes to the HTML body files
- Run the
git add .
command to add all files to git - Run
git commit -m 'testing pipeline trigger'
to commit the changes - Run
git push -u origin master
to upload the code to the repo - Go the the pipeline status screen for your pipeline to verify that the pipeline has triggered
- Verify proper application functionality