Skip to content

Commit 81a8286

Browse files
committed
fixes
1 parent f0a7f69 commit 81a8286

File tree

5 files changed

+64
-39
lines changed

5 files changed

+64
-39
lines changed

content/14-advanced-pipeline/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ ACS is now able to detect and enforce the vulnerability. It is time now to imple
9898

9999
### Let's go: Create our advanced Pipeline
100100

101+
Our current pipeline is quite simple. In production you will have more complex flows with conditionals and parallel execution. To learn more abou these have a look a the [Tekton Documentation]{https://tekton.dev/docs/}.
102+
103+
To make it bit easier we have prepared a pipeline for you. But do take the time to look at the genera flow and tasks.
104+
101105
In the **OpenShift Web Console**:
102106

103107
- Make sure you are in the `workshop-int` Project

content/2-prepare-cluster/_index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ In the cloned repository you'll find a `devfile.yml`. We will need the URL to th
6060

6161
## Install and Prepare CodeReady Workspaces (CRW)
6262

63+
**Codeready Workspaces** is a browser-based IDE for Cloud Native Development. All the heavy lifting is done though a container running your workpsace on OpenShift. All you really need is a laptop. You can easily switch and setup customized environment, plugin, build tools and runtimes. So switching from one project context to another is as easy a switching a website. No more endless installation and configuration marathons on your dev laptop. It is already part your OpenShift subscription. If you want to find out more have a look [here]{https://www.redhat.com/en/technologies/jboss-middleware/codeready-workspaces}
64+
6365
- Install the **Red Hat CodeReady Workspaces for Devfile v1 and v2** Operator from OperatorHub (not the Tech Preview one!) with default settings
6466
- Go to **Installed Operators -> CodeReady Workspaces** and create a new instance (**CodeReady Workspaces instance Specification**) using the default settings in the project `openshift-workspaces`
6567
- Wait until deployment has finished. This may take a couple of minutes as several components will be deployed.
@@ -73,7 +75,7 @@ We could create a workspace from one of the templates that come with CodeReady W
7375
{{% /notice %}}
7476

7577
- At the top click on **Custom Workspace**
76-
- Copy the **raw**(!) URL of the `devfile.yml` file in your `Gitea` repository by clicking on the file and then on the **Raw** button (or **Originalversion** in German).
78+
- Copy the **raw**(Klick in the **Raw** Button) URL of the `devfile.yml` file in your `Gitea` repository by clicking on the file and then on the **Raw** button (or **Originalversion** in German).
7779
- Paste the full URL into the **Enter devfile URL** field and click **Load Devfile**
7880
![Gitea](../images/crw.png)
7981
- Once the content of the devfile is loaded click on **Create & Open** at the button

content/3-inner-loop/_index.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ In this part of the workshop you'll experience how modern software development u
1111
As an example you'll create a new Java application. You don't need to have prior experience programming in Java as this will be kept really simple.
1212

1313
{{% notice tip %}}
14-
We will use a Java application based on the [Quarkus](https://quarkus.io/) stack. Quarkus enables you to create much smaller and faster containerized Java applications than ever before. You can even transcompile these apps to native Linux binaries that start blazingly fast. The app that we will use is just a starter sample created with the [Quarkus Generator](https://code.quarkus.io/) with a simple RESTful API that answers to http Requests. But at the end of the day this setup will work with any Java application. **Fun fact:** Every OpenShift Subscription already comes with a Quarkus Subscription.
14+
We will use a Java application based on the [Quarkus](https://quarkus.io/) stack. Quarkus enables you to create much smaller and faster containerized Java applications than ever before. You can even transcompile these apps to native Linux binaries that start blazingly fast. The app that we will use is just a starter sample created with the [Quarkus Generator](https://code.quarkus.io/) with a simple RESTful API that answers to http Requests. But at the end of the day this setup will work with any Java application. **Fun fact:** Every OpenShift Subscription already comes with a Quarkus Subscription.
1515
{{% /notice %}}
1616

1717
Let's clone our project into our workspace :
18+
1819
- Bring up your `CodeReady Workspaces` in your browser
1920
- In the bottom left click on **Clone Repository** and then enter the `Git URL` to your `Gitea` Repo (You can copy the URL by clicking on the clipboard icon)
2021
- Press enter and select the default location.
@@ -23,6 +24,8 @@ You should be greeted by the `README.md` file.
2324

2425
## Install odo
2526

27+
**odo** or 'OpenShift do' is a cli that enables developers to get started quickly with cloud native app development without being a Kubernetes expert. It offers support for multiple runtimes and you can easily setup microservice components, push code changes into running containers and debug remotely with just a few simple commands. To find out more, have look [here]{https://odo.dev/}
28+
2629
To install the `odo` cli into your workspace, run the following steps:
2730

2831
- From the CRW shortcuts menu to the right (the "cube icon") run `install odo`
@@ -41,38 +44,45 @@ Now we want to create a new OpenShift project for our app:
4144
- In **My Workspace** (cube icon) to the right click `New Terminal`
4245
- Copy the `oc login` command from your OpenShift cluster (At the top right **Username > Copy login command**) and execute in the `terminal` to log into the OpenShift cluster
4346
- Create a new project `workshop-dev`
47+
4448
```
4549
oc new-project workshop-dev
4650
```
4751

4852
## Use odo to Deploy and Update our Application
4953

5054
First use `odo` ("OpenShift Do") to list the programming languages/frameworks it supports
55+
5156
```
5257
./odo catalog list components
5358
```
59+
5460
Now initialize a new Quarkus application
61+
5562
```
5663
./odo create java-quarkus
5764
```
58-
Make the app accessible via http (create a Route)
59-
```
60-
./odo url create workshop-app
61-
```
65+
6266
And finally push the app to OpenShift
67+
6368
```
6469
./odo push
6570
```
71+
6672
To test the app:
73+
6774
- In OpenShift open the `workshop-dev` project and switch to the **Developer Console**
6875
- Open the **Topology** view and click on the top right link of Application icon to display the website of the app
6976
- Your app should show up as a simple web page. In the `RESTEasy JAX-RS` section click the `@Path` endpoint `/hello` to see the result.
7077

7178
Now for the fun part: Using `odo` you can just dynamically change your code and push it out again without doing a new image build! No dev magic involved:
79+
7280
- In your CRW Workspace on the left, expand the file tree to open file `src/main/java/org/acme/GreetingRessource.java` and change the string "Hello RESTEasy" to "Hello Workshop" (CRW saves every edit directly. No need to save)
7381
- Push the code to OpenShift again
82+
7483
```
7584
./odo push
7685
```
86+
7787
- And reload the app webpage.
78-
- Bam! The change should be there in a matter of seconds
88+
- Bam! The change should be there in a matter of seconds

content/5-gitops/_index.md

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@ title = "Configure GitOps"
33
weight = 10
44
+++
55

6-
Now that our CI/CD build and integration stage is ready we could promote the app version directly to a production stage. But with the help of the GitOps approach, we can leverage our Git System to handle promotion that is tracked through commits and can deploy and configure the whole production environment. This stage is just too critical to configure manually and without audit.
6+
Now that our CI/CD build and integration stage is ready we could promote the app version directly to a production stage. But with the help of the GitOps approach, we can leverage our Git System to handle promotion that is tracked through commits and can deploy and configure the whole production environment. This stage is just too critical to configure manually and without audit.
77

8-
## Install OpenShift GitOps
8+
## Install OpenShift GitOps
99

10-
So let's start be installing the OpenShift GitOps Operator based on project ArgoCD.
10+
So let's start be installing the OpenShift GitOps Operator based on project ArgoCD.
1111

1212
- Install the **Red Hat OpenShift GitOps** Operator from OperatorHub with default settings
13-
{{% notice tip %}}
14-
The installation of the GitOps Operator will give you a clusterwide ArgoCD instance available at the link in the top right menu, but since we want to have an instance to manage just our prod namespaces we will create another ArgoCD in that specific namespace.
15-
{{% /notice %}}
13+
{{% notice tip %}}
14+
The installation of the GitOps Operator will give you a clusterwide ArgoCD instance available at the link in the top right menu, but since we want to have an instance to manage just our prod namespaces we will create another ArgoCD in that specific namespace.
15+
{{% /notice %}}
1616
- Create a new OpenShift Project `workshop-prod`
1717
- Then in the project `workshop-prod` click on **Installed Operators** and then **Red Hat OpenShift GitOps**.
1818
- On the **ArgoCD** "tile" click on **Create instance** to create an ArgoCD instance in the `workshop-prod` project.
1919

2020
<!-- ![ArgoCD](../images/argo.png) -->
21+
2122
{{< figure src="../images/argo.png?width=50pc&classes=border,shadow" title="Click image to enlarge" >}}
2223

23-
- Keep the settings as they are and click **Create**
24+
- Keep the settings as they are and click **Create**
2425

25-
## Prepare the GitOps Config Repository
26+
## Prepare the GitOps Config Repository
2627

2728
- In `Gitea` create a **New Migration** and clone the Config GitOps Repo which will be the repository that contains our GitOps infrastructure components and state
2829
- The URL is https://github.com/devsecops-workshop/openshift-gitops-getting-started.git
@@ -33,21 +34,25 @@ Have quick look at the structure of this project :
3334

3435
**environments/dev** - contains the `kustomization.yaml` which will be modified by our builds with new Image versions. ArgoCD will pick up these changes and trigger new deployments.
3536

36-
3737
## Setup GitOps Project
3838

39-
Let's setup the project that tells ArgoCD to watch our config repo and updated resources in the `workshop-prod` project accordingly.
39+
Let's setup the project that tells ArgoCD to watch our config repo and updated resources in the `workshop-prod` project accordingly.
4040

4141
- Give namespace `workshop-prod` permissions to pull images from `workshop-int`
42+
4243
```
4344
oc policy add-role-to-user \
4445
system:image-puller system:serviceaccount:workshop-prod:default \
4546
--namespace=workshop-int
4647
```
48+
4749
- Find the local **ArgoCD URL** by going to **Networking > Routes** in namespace `workshop-prod`
4850
- Open the ArgoCD website ignoring the certificate warning
4951
- Don't login with OpenShift but with username and password
5052
- User is `admin` and password will be in Secret `argocd-cluster`
53+
54+
ArgoCD works with the concept of **Apps**. We will create an App and point it to the Config Git Repo. ArgoCD will look for k8s yaml files in the repo and path and deploy them to the defined namespace. Additionally ArgoCD will also react to changes to the repo and reflect these to the namespace. You can also enable self-healing to prevent configuration drift. If you want find out more about OpenShift GitOps have look [here]{https://docs.openshift.com/container-platform/4.10/cicd/gitops/understanding-openshift-gitops.html} :
55+
5156
- Create App
5257
- Click the **Manage your applications** icon on the left
5358
- Click **Create Application**
@@ -59,13 +64,14 @@ oc policy add-role-to-user \
5964
- **Cluster URL**: https://kubernetes.default.svc
6065
- **Namespace**: workshop-prod
6166
- Click **Create**
62-
- Click on **Sync** and then **Synchronize** to manually trigger the first sync
67+
- Click on **Sync** and then **Synchronize** to manually trigger the first sync
68+
- Click on the `workshop` to show the deployment graph
6369

64-
Watch the resources (`Deployment`, `Service`, `Route`) get rolled out to the namespace `workshop-prod`. Notice we have also scaled our app to 2 pods in the prod stage as we want some HA.
70+
Watch the resources (`Deployment`, `Service`, `Route`) get rolled out to the namespace `workshop-prod`. Notice we have also scaled our app to 2 pods in the prod stage as we want some HA.
6571

66-
Our complete prod stage is now configured and controlled though GitOps. But how do we tell ArgoCD that there is a new version of our app to deploy? Well, we will add a step to our build pipeline updating the config repo.
72+
Our complete prod stage is now configured and controlled though GitOps. But how do we tell ArgoCD that there is a new version of our app to deploy? Well, we will add a step to our build pipeline updating the config repo.
6773

68-
As we do not want to modify our original repo file we will use a tool called [Kustomize](https://kustomize.io/) that can add incremental change layers to YAML files. Since ArgoCD permanently watches this repo it will pick up these Kustomize changes.
74+
As we do not want to modify our original repo file we will use a tool called [Kustomize](https://kustomize.io/) that can add incremental change layers to YAML files. Since ArgoCD permanently watches this repo it will pick up these Kustomize changes.
6975

7076
{{% notice tip %}}
7177
It is also possible to update the repo with a Pull request. Then you have an approval process for your prod deployment.
@@ -77,6 +83,7 @@ Let's add a new custom Tekton task that can update the Image `tag` via Kustomize
7783

7884
- In the namespace `workshop-int` switch to the **Administrator** Perspective and go to **Pipelines > Tasks > Create Task**
7985
- Replace the YAML definition with the following and click **Create**:
86+
8087
```yaml
8188
apiVersion: tekton.dev/v1beta1
8289
kind: Task
@@ -87,7 +94,7 @@ metadata:
8794
name: git-update-deployment
8895
namespace: workshop-int
8996
labels:
90-
app.kubernetes.io/version: '0.1'
97+
app.kubernetes.io/version: "0.1"
9198
operator.tekton.dev/provider-type: community
9299
spec:
93100
description: This Task can be used to update image digest in a Git repo using kustomize
@@ -110,14 +117,14 @@ spec:
110117
- description: The commit SHA
111118
name: commit
112119
steps:
113-
- image: 'docker.io/alpine/git:v2.26.2'
120+
- image: "docker.io/alpine/git:v2.26.2"
114121
name: git-clone
115122
resources: {}
116123
script: |
117124
rm -rf git-update-digest-workdir
118125
git clone $(params.GIT_REPOSITORY) git-update-digest-workdir
119126
workingDir: $(workspaces.workspace.path)
120-
- image: 'quay.io/wpernath/kustomize-ubi:latest'
127+
- image: "quay.io/wpernath/kustomize-ubi:latest"
121128
name: update-digest
122129
resources: {}
123130
script: >
@@ -159,7 +166,7 @@ spec:
159166
160167
cat kustomization.yaml
161168
workingDir: $(workspaces.workspace.path)
162-
- image: 'docker.io/alpine/git:v2.26.2'
169+
- image: "docker.io/alpine/git:v2.26.2"
163170
name: git-commit
164171
resources: {}
165172
script: >
@@ -225,19 +232,19 @@ spec:
225232
workspaces:
226233
- description: The workspace consisting of maven project.
227234
name: workspace
228-
229235
```
230236
231237
## Add Tekton Task to Your Pipeline
232238
233239
- Go to **Pipeline > Pipelines > workshop** and then YAML
234240
235241
{{% notice tip %}}
236-
You can edit pipelines either directly in YAML or in the visual **Pipeline Builder**. We will see how to use the Builder later on so let's edit the YAML for now.
242+
You can edit pipelines either directly in YAML or in the visual **Pipeline Builder**. We will see how to use the Builder later on so let's edit the YAML for now.
237243
{{% /notice %}}
238-
244+
239245
Add the new Task to your Pipeline by adding it to the YAML like this:
240-
- In the YAML view insert it at the **tasks** level after the `deploy` task
246+
247+
- In the YAML view insert it at the **tasks** level after the `deploy` task
241248
- For the `param` `GIT_REPOSITORY` use your git config repo url (eg. replace {YOUR DOMAIN})
242249
- Make sure to fix indentation after pasting into the YAML!
243250

@@ -275,45 +282,47 @@ In the OpenShift YAML viewer/editor you can mark multiple lines and use **tab**
275282
workspace: workspace
276283
277284
```
285+
278286
The `Pipeline` should now look like this
279287

280288
<!-- ![workshop Pipeline](../images/tekton.png) -->
281-
{{< figure src="../images/tekton.png?width=50pc&classes=border,shadow" title="Click image to enlarge" >}}
289+
290+
{{< figure src="../images/pipeline1.png?width=50pc&classes=border,shadow" title="Click image to enlarge" >}}
282291

283292
- Create a secret with credentials for your `Gitea` repository, so the `task` can authenticate and push to `Gitea`. Replace {YOUR DOMAIN} here to match your `Gitea`URL
284293
- You can add this by clicking on the **+** on the top right ob the Web Console
294+
285295
```yaml
286296
kind: Secret
287297
apiVersion: v1
288298
metadata:
289299
name: gitea
290300
namespace: workshop-int
291301
annotations:
292-
tekton.dev/git-0: 'https://repository-git.apps.{YOUR DOMAIN}'
302+
tekton.dev/git-0: "https://repository-git.apps.{YOUR DOMAIN}"
293303
data:
294304
password: Z2l0ZWE=
295305
username: Z2l0ZWE=
296306
type: kubernetes.io/basic-auth
297307
```
298-
Now we need to add the secret to the `serviceaccount` that runs our pipelines so the `task` can push to our config repo.
308+
309+
Now we need to add the secret to the `serviceaccount` that runs our pipelines so the `task` can push to our config repo.
299310

300311
- Go to **User Management > ServiceAccounts > pipeline**
301312
- To make the secret available during a pipeline run: Open the YAML and in the `secrets` section add:
302313

303314
```yaml
304-
- name: gitea
315+
- name: gitea
305316
```
317+
306318
- Save and ignore the warning
307319

308320
## Update our Prod Stage via Pipeline and GitOps
309321

310322
- Run the pipeline and see that in your Gitea repo `/environment/dev/kustomize.yaml` is updated with the new image version
311-
{{% notice tip %}}
312-
Notice that the `deploy` and the `git-update` steps now run in parallel. This is one of the powers of Tekton. It can scale natively with pods on OpenShift.
313-
{{% /notice %}}
314-
323+
{{% notice tip %}}
324+
Notice that the `deploy` and the `git-update` steps now run in parallel. This is one of the powers of Tekton. It can scale natively with pods on OpenShift.
325+
{{% /notice %}}
315326

316327
- This will tell ArgoCD to update the `Deployment` with this new image version
317328
- Check that the new image is rolled out (you may need to sync manually in ArgoCD to speed things up)
318-
319-

static/images/pipeline1.png

25.6 KB
Loading

0 commit comments

Comments
 (0)