Skip to content

Commit 565662b

Browse files
authored
Merge branch 'main' into gls-edit-non-funct-map
2 parents 65269b3 + 7731a1a commit 565662b

File tree

13 files changed

+362
-141
lines changed

13 files changed

+362
-141
lines changed

docs/1-the-manual-menace/1-the-basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ oc new-project ${TEAM_NAME}-ci-cd
4949
![new-project](./images/new-project.png)
5050

5151
### Helm 101
52-
> Helm is the package manager for Kubernetes. It provides a way to templatise the Kubernetes YAML that make up our application. The Kubernetes resources such as `DeploymentConfig`, `Route` & `Service` can be processed by supplying `values` to the templates. In Helm land, there are a few ways to do this. A package containing the templates and their default values is called a `chart`.
52+
> Helm is the package manager for Kubernetes. It provides a way to create templates for the Kubernetes YAML that defines our application. The Kubernetes resources such as `DeploymentConfig`, `Route` & `Service` can be processed by supplying `values` to the templates. In Helm land, there are a few ways to do this. A package containing the templates and their default values is called a `chart`.
5353
5454
Let's deploy a simple application using Helm.
5555

docs/1-the-manual-menace/4-extend-uj.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ git pull
2121
enabled: true
2222
source: https://redhat-cop.github.io/helm-charts
2323
chart_name: sonatype-nexus
24-
source_ref: "1.1.2"
24+
source_ref: "1.1.3"
2525
values:
2626
service:
2727
name: nexus

docs/3-revenge-of-the-automated-testing/5b-tekton.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Let's run through a scenario where we break/fix the build with **kube-linter**.
167167
8. We can check the **kube-linter** command again and check these changes in:
168168

169169
```bash
170-
cd /project/pet-battle-api
170+
cd /projects/pet-battle-api
171171
git add .
172172
git commit -m "🐊 ADD - kube-linter owner labels 🐊"
173173
git push

docs/3-revenge-of-the-automated-testing/8-image-signing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727

2828
You just generated two keys (one private key, one public key). Private key is used to sign the images and it is automatically saved as a secret in your `ci-cd` namespace alongside the password you choose. Public key is used to verify the signed images. You can share your public key for people to verify your images but private one should not be shared or at least sealed before storing publicly.
2929

30+
<p class="tip">
31+
🐌 THIS IS NOT GITOPS - The generated private key is stored in a Kubernetes secret in you <TEAM_NAME>-ci-cd project. We'll leave it as an exercise to the reader to extract and store this as a SealedSecret instead! 🐎
32+
</p>
33+
34+
3035
Now let's proceed to extend the pipelines with image signing step.
3136

3237
_This step makes more sense when you use an external image registry and share images across clusters or publicly._

docs/3-revenge-of-the-automated-testing/8b-tekton.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@
9292
9393
![cosign-image-signing](images/cosign-image-signing.png)
9494
95-
5. Let's verify the signed image with the public key. Make sure you use the right `APP VERSION` for the image. (`1.3.1` in this case)
95+
5. Let's verify the signed image with the public key. Make sure you use the right `APP VERSION` for the image. (`1.2.0` in this case)
9696
9797
```bash
9898
cd /projects/pet-battle-api
9999
oc registry login $(oc registry info) --insecure=true
100-
cosign verify --key k8s://<TEAM_NAME>-ci-cd/<TEAM_NAME>-cosign default-route-openshift-image-registry.<CLUSTER_DOMAIN>/<TEAM_NAME>-test/pet-battle-api:1.3.1
100+
cosign verify --key k8s://<TEAM_NAME>-ci-cd/<TEAM_NAME>-cosign default-route-openshift-image-registry.<CLUSTER_DOMAIN>/<TEAM_NAME>-test/pet-battle-api:1.2.0
101101
```
102102
103103
The output should be like:
104104
105105
<div class="highlight" style="background: #f7f7f7">
106106
<pre><code class="language-bash">
107-
Verification for default-route-openshift-image-registry.<CLUSTER_DOMAIN>/<TEAM_NAME>-test/pet-battle-api:1.3.1 --
107+
Verification for default-route-openshift-image-registry.<CLUSTER_DOMAIN>/<TEAM_NAME>-test/pet-battle-api:1.2.0 --
108108
The following checks were performed on each of these signatures:
109109
- The cosign claims were validated
110110
- The signatures were verified against the specified public key
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
## Here be dragons!
2+
3+
![oh-look-a-dragon](../images/oh-look-dragons.png)
4+
5+
### Moving from one cluster to another!
6+
7+
Because all of our code and configuration is in git, we can easily move our whole continuous delivery stack to another OpenShift cluster. This is useful if you wanted to try out all the exercises at a later stage using the code from this run.
8+
9+
As a prerequisite - you will need to have setup TL500 using the previous section [Tooling Installation](99-the-rise-of-the-cluster/1-tooling-installation). Lets cover the steps once you have a cluster and tooling installed to get going with your code.
10+
11+
Lets take our code from `cluster-a` to `cluster-b`.
12+
13+
#### Guided Steps
14+
15+
> Here are the short series of steps to make this work.
16+
17+
1. You will need to git clone the `tech-exercise`, `pet-battle`, `pet-battle-api` repositories to your laptop for safe-keeping after taking this course.
18+
19+
2. Use `vscode` IDE or similar to replace all the occurrances of `apps.cluster-a.com -> apps.cluster-b.com` in the code.
20+
21+
3. Login to `gitlab` and create your ${TEAM_NAME}
22+
23+
4. Let's push our code into the hosted `gitlab` instance in our new cluster:
24+
25+
```bash
26+
export GIT_SERVER=gitlab-ce.apps.cluster-b.com
27+
export TEAM_NAME=ateam
28+
```
29+
30+
I'm assuming the code is in this folder locally on my laptop, adjust to suit. For each of the repos:
31+
32+
`Pet-Battle`
33+
34+
```bash
35+
cd ~/git/tl500/pet-battle
36+
git remote set-url origin https://${GIT_SERVER}/${TEAM_NAME}/pet-battle.git
37+
git push -u origin main
38+
```
39+
40+
`Pet-Battle-API`
41+
42+
```bash
43+
cd ~/git/tl500/pet-battle-api
44+
git remote set-url origin https://${GIT_SERVER}/${TEAM_NAME}/pet-battle-api.git
45+
git push -u origin main
46+
```
47+
48+
`Tech-Exercise`
49+
50+
```bash
51+
cd ~/git/tl500/tech-exercise
52+
git remote set-url origin https://${GIT_SERVER}/${TEAM_NAME}/tech-exercise.git
53+
git push -u origin main
54+
```
55+
56+
5. Login to `gitlab` and make sure your newly created projects are set to **public** (they will be private by default).
57+
58+
6. Regenerate the `sealed-secrets` for this new cluster. This assumes we did _not_ migrate the secret master key to the new cluster when setting up (obviously skip this step if you did migrate it!).
59+
60+
Set `git-auth`
61+
62+
```bash
63+
export GITLAB_USER=<user>
64+
export GITLAB_PASSWORD=<password>
65+
66+
cat << EOF > /tmp/git-auth.yaml
67+
kind: Secret
68+
apiVersion: v1
69+
data:
70+
username: "$(echo -n ${GITLAB_USER} | base64 -w0)"
71+
password: "$(echo -n ${GITLAB_PASSWORD} | base64 -w0)"
72+
metadata:
73+
annotations:
74+
tekton.dev/git-0: https://${GIT_SERVER}
75+
labels:
76+
credential.sync.jenkins.openshift.io: "true"
77+
name: git-auth
78+
EOF
79+
80+
kubeseal < /tmp/git-auth.yaml > /tmp/sealed-git-auth.yaml \
81+
-n ${TEAM_NAME}-ci-cd \
82+
--controller-namespace tl500-shared \
83+
--controller-name sealed-secrets \
84+
-o yaml
85+
```
86+
87+
Set `sonarqube-auth`
88+
89+
```bash
90+
cat << EOF > /tmp/sonarqube-auth.yaml
91+
apiVersion: v1
92+
data:
93+
username: "$(echo -n admin | base64 -w0)"
94+
password: "$(echo -n admin123 | base64 -w0)"
95+
currentAdminPassword: "$(echo -n admin | base64 -w0)"
96+
kind: Secret
97+
metadata:
98+
labels:
99+
credential.sync.jenkins.openshift.io: "true"
100+
name: sonarqube-auth
101+
EOF
102+
103+
kubeseal < /tmp/sonarqube-auth.yaml > /tmp/sealed-sonarqube-auth.yaml \
104+
-n ${TEAM_NAME}-ci-cd \
105+
--controller-namespace tl500-shared \
106+
--controller-name sealed-secrets \
107+
-o yaml
108+
109+
cat /tmp/sealed-sonarqube-auth.yaml| grep -E 'username|password|currentAdminPassword'
110+
```
111+
112+
Set `allure-auth`
113+
114+
```bash
115+
cat << EOF > /tmp/allure-auth.yaml
116+
apiVersion: v1
117+
data:
118+
password: "$(echo -n password | base64 -w0)"
119+
username: "$(echo -n admin | base64 -w0)"
120+
kind: Secret
121+
metadata:
122+
name: allure-auth
123+
EOF
124+
125+
kubeseal < /tmp/allure-auth.yaml > /tmp/sealed-allure-auth.yaml \
126+
-n ${TEAM_NAME}-ci-cd \
127+
--controller-namespace tl500-shared \
128+
--controller-name sealed-secrets \
129+
-o yaml
130+
131+
cat /tmp/sealed-allure-auth.yaml| grep -E 'username|password'
132+
```
133+
134+
Set `rox-auth`
135+
136+
```bash
137+
export ROX_API_TOKEN=$(oc -n stackrox get secret rox-api-token-tl500 -o go-template='{{index .data "token" | base64decode}}')
138+
export ROX_ENDPOINT=central-stackrox.apps.cluster-b.com
139+
140+
cat << EOF > /tmp/rox-auth.yaml
141+
apiVersion: v1
142+
data:
143+
password: "$(echo -n ${ROX_API_TOKEN} | base64 -w0)"
144+
username: "$(echo -n ${ROX_ENDPOINT} | base64 -w0)"
145+
kind: Secret
146+
metadata:
147+
labels:
148+
credential.sync.jenkins.openshift.io: "true"
149+
name: rox-auth
150+
EOF
151+
152+
kubeseal < /tmp/rox-auth.yaml > /tmp/sealed-rox-auth.yaml \
153+
-n ${TEAM_NAME}-ci-cd \
154+
--controller-namespace tl500-shared \
155+
--controller-name sealed-secrets \
156+
-o yaml
157+
158+
cat /tmp/sealed-rox-auth.yaml | grep -E 'username|password'
159+
```
160+
161+
7. Run the basics
162+
163+
```bash
164+
export TEAM_NAME="ateam"
165+
export CLUSTER_DOMAIN="apps.cluster-b.com"
166+
export GIT_SERVER="gitlab-ce.apps.cluster-b.com"
167+
168+
oc login --server=https://api.${CLUSTER_DOMAIN##apps.}:6443 -u mike
169+
```
170+
171+
8. Install ArgoCD
172+
173+
Add our namespace to the operator env.var:
174+
175+
```bash
176+
run()
177+
{
178+
NS=$(oc get subscription/openshift-gitops-operator -n openshift-operators \
179+
-o jsonpath='{.spec.config.env[?(@.name=="ARGOCD_CLUSTER_CONFIG_NAMESPACES")].value}')
180+
if [ -z $NS ]; then
181+
NS="${TEAM_NAME}-ci-cd"
182+
elif [[ "$NS" =~ .*"${TEAM_NAME}-ci-cd".* ]]; then
183+
echo "${TEAM_NAME}-ci-cd already added."
184+
return
185+
else
186+
NS="${TEAM_NAME}-ci-cd,${NS}"
187+
fi
188+
oc -n openshift-operators patch subscription/openshift-gitops-operator --type=json \
189+
-p '[{"op":"replace","path":"/spec/config/env/1","value":{"name": "ARGOCD_CLUSTER_CONFIG_NAMESPACES", "value":"'${NS}'"}}]'
190+
echo "EnvVar set to: $(oc get subscription/openshift-gitops-operator -n openshift-operators \
191+
-o jsonpath='{.spec.config.env[?(@.name=="ARGOCD_CLUSTER_CONFIG_NAMESPACES")].value}')"
192+
}
193+
run
194+
```
195+
196+
Deploy helm chart
197+
198+
```bash
199+
oc new-project ${TEAM_NAME}-ci-cd
200+
helm repo add redhat-cop https://redhat-cop.github.io/helm-charts
201+
202+
helm upgrade --install argocd \
203+
--namespace ${TEAM_NAME}-ci-cd \
204+
-f tech-exercises/argocd-values.yaml \
205+
redhat-cop/gitops-operator
206+
```
207+
208+
9. Install UJ
209+
210+
```bash
211+
cd tech-exercises
212+
helm upgrade --install uj --namespace ${TEAM_NAME}-ci-cd .
213+
```
214+
215+
10. Add the integrations and web hooks to gitlab for `tech-exercise`, `pet-battle`, `pet-battle-api` git repos
216+
217+
11. Kick off builds, make sure they work, fix up and helm chart version mismatches etc.
218+
219+
12. 🎉🎉🎉 Celebrate a successful migration to a new cluster 🎉🎉🎉

docs/_sidebar.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@
5353
* [🪄 A/B Deployments](5-the-deployments-strike-back/3-a-b-deployments.md)
5454
* [🐉 Here Be Dragons!](5-the-deployments-strike-back/666-here-be-dragons.md)
5555
* [99. Rise of the Cluster](99-the-rise-of-the-cluster/README.md)
56-
* [🐼 Tooling Installation](99-the-rise-of-the-cluster/1-tooling-installation.md)
56+
* [🐼 Tooling Installation](99-the-rise-of-the-cluster/1-tooling-installation.md)
57+
* [🐉 Here Be Dragons!](99-the-rise-of-the-cluster/666-here-be-dragons.md)
-30.9 KB
Loading

0 commit comments

Comments
 (0)