Skip to content

Commit 403fed0

Browse files
cicd steps updated
1 parent 682b7b8 commit 403fed0

1 file changed

Lines changed: 28 additions & 37 deletions

File tree

CICD/cicd-steps.txt

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Machine 2: This VM will be your Jenkins server (CI/CD server)
1111
Machine 1 can be your personal Laptop or a cloud VM.
1212

1313
Machine 2 *has* to be a cloud VM (such as a EC2 instance).
14-
Feel free to choose either a EC2 instance or Google Compute Engine instance
14+
1515
Make sure you allow TCP traffic to port 8080 on your VM instance.
1616

1717

@@ -37,7 +37,7 @@ A] Setup your developer workspace/Machine 1:
3737
4) Create testdb database on the Cloud SQL instance
3838
- gcloud sql instances list
3939
- Once the Cloud SQL instance is in 'RUNNABLE' state, do following steps:
40-
- gcloud sql users set-password root % --instance instance1 --password 'testpass123!@#'
40+
- gcloud sql users set-password root --host % --instance instance1 --password 'testpass123!@#'
4141
- sudo apt-get install mysql-client
4242
- mysql -h <IP-address-of-SQL-Instance> --user=root --password='testpass123!@#'
4343
- mysql>create database testdb;
@@ -54,14 +54,16 @@ A] Setup your developer workspace/Machine 1:
5454
- Make it Public
5555
- Generate a SSH Key pair for your developer workspace VM
5656
and add it to your Bitbucket account
57-
- Account -> Settings -> Add Key
57+
- Account -> Bitbucket settings -> SSH keys -> Add key
58+
- On your machine generate ssh key as follows (steps given for Linux/Unix):
5859
- ssh-keygen
5960
- It is fine if you provide an empty passphrase
6061
- more ~/.ssh/id_rsa.pub
6162
- Copy the key and paste it in the "Add Key" box in Bitbucket.
6263
- When you paste the key, make sure that there are no extra spaces between the characters.
6364
The pasting operation will unevenly break the key into multiple lines. Find such lines
6465
and remove any extra spaces by hitting the Backspace key.
66+
- Best approach is to copy and paste each line without leaving any spaces when you paste a line.
6567

6668
8) Download Sample CI/CD project
6769
- git clone https://github.com/devdattakulkarni/CloudComputing
@@ -71,10 +73,13 @@ A] Setup your developer workspace/Machine 1:
7173
(Note: In the image tag don't include any version.
7274
i.e.: Define your image tag as: "gcr.io/<project-id>/greetings:latest" and NOT as
7375
"gcr.io/<project-id>/greetings:v1")
76+
- Save and commit the modifications:
77+
- git add
78+
- git commit
7479

7580
- Add a remote for your Bitbucket repository and Push the sample CI/CD project to that remote
7681
- cd ../../
77-
- git remote add origin1 git@bitbucket.org:<your-bitbucket-username>/assignment6.git
82+
- git remote add origin1 git@bitbucket.org:<your-bitbucket-username>/assignment4.git
7883
- git push origin1 master
7984

8085

@@ -111,12 +116,11 @@ B] Setup your Jenkins Server/Machine 2:
111116
The pasting operation will unevenly break the key into multiple lines. Find such lines
112117
and remove any extra spaces by hitting the Backspace key.
113118

114-
- Workaround (If running into SSH host key verification issues, you can disable it as follows):
115-
- Disable Host key verification:
116-
- create .ssh/config file
117-
- Include following lines in it:
118-
Host *
119-
StrictHostKeyChecking no
119+
- Disable Host key verification:
120+
- create .ssh/config file
121+
- Include following lines in it:
122+
Host *
123+
StrictHostKeyChecking no
120124

121125
2) Configure authentication for gcloud CLI
122126
- gcloud auth login --> Follow the prompts (you will have to open browser window and paste the generated link,
@@ -128,28 +132,31 @@ B] Setup your Jenkins Server/Machine 2:
128132
- gcloud config set project ${PROJECT_ID}
129133

130134

131-
3) Download and Start Jenkins Server:
135+
3) Configure kubectl to connect to your GKE cluster
136+
- gcloud container clusters get-credentials testcluster1
137+
138+
4) Download and Start Jenkins Server:
132139
- wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
133140
- nohup java -jar jenkins.war --httpPort=8080 &
134141
-> This will start Jenkins process on port 8080
135142

136-
4) Configure Jenkins Server
143+
5) Configure Jenkins Server
137144
- Point your browser to the DNS name of the Jenkins Server at port 8080
138145
https://<DNS-of-Jenkins-Server>:8080/
139146
- Enter admin password from $HOME/.jenkins/secrets/initialAdminPassword
140147
- Choose Install suggested plugins option
141148

142-
5) Once Jenkins starts up do following:
143-
5.1) Login as admin user
149+
6) Once Jenkins starts up do following:
150+
6.1) Login as admin user
144151
- Password is stored in: $HOME/.jenkins/secrets/initialAdminPassword
145-
5.2) Set the path in Jenkins for Git
152+
6.2) Set the path in Jenkins for Git
146153
Jenkins -> Manage Jenkins -> Configure System -> Global Properties
147154
- Check Tool Locations
148155
- List of tool locations -> Add
149156
- Set the path of Git from your VM
150157
(You can find the path by running 'which git' on VM)
151158
- Save
152-
5.3) Install the Post build task Plugin and Bitbucket Plugin
159+
6.3) Install the Post build task Plugin and Bitbucket Plugin
153160
Jenkins -> Manage Jenkins -> Manage Plugins
154161
- In Available tab, search "Post build task" and select
155162
- In Available tab, search "Bitbucket" and select
@@ -187,21 +194,14 @@ C] Add a WebHook to your Bitbucket repository
187194
- Notes:
188195
- First modify build-steps.txt to use your GCP Project ID
189196
- Make sure that the image tag that use here is what you defined
190-
in deployment.yaml (Part A, step 7)
197+
in deployment.yaml (Part A, step 8)
191198
2.5) In Post-build Actions
192199
-> Add post-build action -> Post build task
193200
-> Log text "SUCCESS" -> Operation "-- OR --"
194201
-> In the Tasks -> Script section:
195202
- Add contents of deploy-steps.txt (modify the steps as required)
196203
2.6) Save
197204

198-
2.7) Bitbucket host key verification
199-
200-
Once you hit 'Save', you will see a prompt to verify the key for bitbucket server.
201-
This indicates that Jenkins has received the web hook and wants to clone your repository.
202-
In order to clone the repo, it needs to first verify the host key. Enter 'yes' to accept
203-
the specified host key.
204-
205205

206206
CI/CD Experiment:
207207
-----------------
@@ -213,18 +213,12 @@ CI/CD Experiment:
213213
- git commit
214214
- git push origin1 master
215215

216-
3) If Part C step 2.7 was not executed for some reason, on the Jenkins server,
217-
you should see a prompt to verify the key for bitbucket server.
218-
This indicates that Jenkins has received the web hook and wants to clone your repository.
219-
In order to clone the repo, it needs to first verify the host key. Enter 'yes' to accept
220-
the specified host key.
221-
222-
4) In the Jenkins Job you should see a new build triggered (visible under "Build History")
216+
3) In the Jenkins Job you should see a new build triggered (visible under "Build History")
223217
- Select the Build
224218
- Go to Console Output
225219
- Verify that the build and deploy steps have been executed
226220

227-
5) On Machine 2 (Jenkins server):
221+
4) On Machine 2 (Jenkins server):
228222
- kubectl get ingress
229223
- Check the AGE field. It usually takes 7/8 minutes before the changes are reflected
230224
on the Ingress IP address
@@ -265,12 +259,9 @@ Troubleshooting:
265259
- On Machine 2 find out Jenkins process
266260
- ps -eaf | grep java
267261
- kill <process-id>
268-
- Re-run Jenkins using the java command (Part B step 2)
269-
270-
2) Jenkins URL location
271-
Jenkins -> Manage Jenkins -> Jenkins Location
262+
- Re-run Jenkins using the java command (Part B step 4)
272263

273-
3) Jenkins workspace
264+
2) Jenkins workspace
274265
- On Jenkins Server at $HOME/.jenkins/workspace
275266
- This is the location where repository is cloned corresponding to Jenkins Jobs
276267

0 commit comments

Comments
 (0)