Skip to content

Commit 21580ba

Browse files
authored
feat: Clean + refactor (#8)
1 parent a337e4b commit 21580ba

File tree

12 files changed

+28
-120
lines changed

12 files changed

+28
-120
lines changed

README.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,26 @@
44

55
You can read the article at:
66

7-
- On my personal portfolio website: <https://lucabertelli.consulting/en/blog/vcluster>
7+
- My portfolio website: <https://lucabertelli.consulting/en/blog/vcluster>
88
- On Medium: <https://medium.com/@bertelli.luca/ephemeral-test-environments-for-ci-workflows>
99

10-
## How to use vCluster, ArgoCD Events and Argo Workflow to manage short-live test ephemeral environments
10+
## How to use vCluster and Argo Workflow to manage ephemeral test environments
1111

1212
Project structure:
1313

1414
```text
1515
.
16-
├── argo
17-
│ ├── events
18-
│ └── workflow
19-
│ └── lang
20-
├── hello-world-app
21-
└── vcluster
16+
├── argo-workflow
17+
│ └── lang
18+
└── hello-world-app
2219
```
2320

24-
- `argo` folder: All configurations made for
25-
- `events`: Argo Events webhook, trigger (for Argo Workflow), and sensor
26-
- `workflow`: CI/CD pipeline triggered by Argo Events
27-
- `lang`: ArgoWorkflow Templates for supported languages
21+
- `argo-workflow`: CI/CD pipeline templates
22+
- `lang`: ArgoWorkflow Templates for supported languages
2823
- `hello-world-app` folder: Go Hello world application that prints a beautiful octopus 🐙 in ASCII code
29-
- `vcluster` folder: All configurations made for creating VCluster where deploy the hello world application
3024

3125
Key highlights from the article include:
3226

33-
1. **vCluster Usage**: The article introduces vCluster as a pivotal tool for creating lightweight, ephemeral Kubernetes clusters. It's so interesting how vCluster can be employed to instantiate and manage test environments on-demand, covering the scenarios where temporary clusters are essential for testing purposes.
27+
1. **vCluster Usage**: The article introduces vCluster as a pivotal tool for creating lightweight, ephemeral Kubernetes clusters. It's interesting how vCluster can be employed to instantiate and manage test environments on-demand, covering the scenarios where temporary clusters are essential for testing.
3428

35-
2. **Argo Events Integration**: The article explores the integration of Argo Events, a tool designed for event-driven architecture in Kubernetes. It details how Argo Events can be utilized to trigger and manage events received from the SCM to manage the lifecycle of short-lived test environments. This allows for dynamic and automated responses to changes in the testing and security requirements.
36-
37-
3. **Argo Workflow Implementation**: The article delves into the integration of Argo Workflow, a workflow engine for Kubernetes. It provides insights into how Argo Workflow can be configured to orchestrate the deployment, testing, and teardown processes efficiently. The tool enables the final user to define also another kind of process drawing DAGs (<https://argoproj.github.io/argo-workflows/walk-through/dag/>). This feature supports complex scenarios where there is a requirement to maximize parallelism when running tasks.
29+
2. **Argo Workflow Implementation**: The article delves into the integration of Argo Workflow, a workflow engine for Kubernetes, providing a way to configure the orchestration of the deployment, testing, and teardown processes efficiently. The tool also enables the final user to define another kind of process drawing DAGs (<https://argoproj.github.io/argo-workflows/walk-through/dag/>). This feature supports complex scenarios where there is a requirement to maximize parallelism when running tasks.
Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration of Argo Workflow entities
22

3-
## Prerequisites
3+
## Requirements
44

55
- Minikube
66
- `kubectl` command-line tool installed and configured to connect to your Kubernetes cluster.
@@ -13,7 +13,7 @@
1313
```bash
1414
minikube start
1515
helm repo add argo https://argoproj.github.io/argo-helm
16-
helm install argo-workflows argo/argo-workflows
16+
helm install argo-workflows argo/argo-workflows -n argo --create-namespace
1717
```
1818

1919
This command installs Argo Workflows in the default namespace of your Kubernetes cluster.
@@ -53,11 +53,11 @@ Argo Workflows provides a web-based UI for managing and monitoring workflows. To
5353
kubectl port-forward svc/argo-server -n argo 2746:2746
5454
```
5555

56-
Now you can access the Argo Workflows UI by navigating to `http://localhost:2746` in your web browser.
56+
Now, you can access the Argo Workflows UI by navigating to `http://localhost:2746` in your web browser.
5757

5858
### 5. Add privileges to Argo service accounts
5959

60-
> Add this privileges to the Argo service accounts are recommended only for demo purposes. **IT'S STRONGLY NOT RECOMMENDED TO REPLICATE THIS CONFIGURATION IN PRODUCTION EVINRONMENTS.**
60+
> Add these privileges to the Argo service accounts are recommended only for demo purposes. **IT'S STRONGLY NOT RECOMMENDED TO REPLICATE THIS CONFIGURATION IN PRODUCTION ENVIRONMENTS.**
6161
6262
This command adds `cluster-admin` clusterrole to `argo:argo-server` and `argo:default`. In this way, Argo Workflow can manage every kind of resource in every namespace of the cluster.
6363

@@ -66,11 +66,11 @@ kubectl create clusterrolebinding argo-admin-server --clusterrole=cluster-admin
6666
kubectl create clusterrolebinding argo-admin-default --clusterrole=cluster-admin --serviceaccount=argo:default -n argo
6767
```
6868

69-
> In production evironments it's strongly recommended to create a dedicated role to these service accounts allowing only required verbs on the resources managed by the workflows.
69+
> In production environments, creating a dedicated role for these service accounts is strongly recommended, allowing only required verbs on the resources managed by the workflows.
7070
7171
### 6. Prepare secrets required by the pipelines
7272

73-
Just in case of a private Git repository you can run this command to allow the clone command executed by the pipeline `ci.yaml`:
73+
Just in case of a private Git repository, you can run this command to allow the clone command executed by the pipeline `ci.yaml`:
7474

7575
```bash
7676
kubectl create secret generic github-token -n argo --from-literal=token=.........
@@ -111,18 +111,16 @@ Alternatively, you can submit the workflow using the UI:
111111

112112
![Submit CI workflow via UI](images/1_ci_submit.png)
113113

114-
The CI pipeline performs these steps:
114+
The CI pipeline performs these steps inside the [ci.yaml](https://github.com/banshee86vr/ephemeral-test-environment/blob/main/argo-workflow/ci.yaml) manifest:
115115

116116
1. **Cloning Repository**: Fetches the source code from the git repository.
117-
2. **Building Application**: Utilizes the GoLang template to compile the Go application.
117+
2. **Building Application**: Utilizes the GoLang template [go.yaml](https://github.com/banshee86vr/ephemeral-test-environment/blob/main/argo-workflow/lang/go.yaml) to compile the Go application.
118118
3. **Building and Pushing Docker Image**: Packages the application into a Docker image and pushes it to the registry.
119119

120-
After the completion of all steps, you can check the correct status of every step:
120+
After the completion of all steps, you can check the correct status of every step and locate the updated Docker image in your registry:
121121

122122
![CI workflow graph](images/2_ci_graph.png)
123123

124-
If all steps have been completed, you can find a new version of the Docker image in your registry.
125-
126124
### 9. Submit the CD pipeline
127125

128126
To submit the CD pipeline, you can use the [official APIs](https://argo-workflows.readthedocs.io/en/latest/rest-api/):
@@ -135,17 +133,15 @@ Alternatively, you can submit the workflow using the UI:
135133

136134
![Submit CD workflow via UI](images/3_cd_submit.png)
137135

138-
The CD pipeline performs these steps:
136+
The CD pipeline performs these steps inside the [cd.yaml](https://github.com/banshee86vr/ephemeral-test-environment/blob/main/argo-workflow/cd.yaml) manifest:
139137

140-
1. **Preparing an ephemeral environment**: Prepares an ephemeral environment using vCluster where the user can test the application inside an isolated Kubernetes cluster
141-
2. **Deploy the application**: Deploy the application Helm chart on the vCluster just created
138+
1. **Preparing an ephemeral environment**: Prepares a temporary environment using vCluster where the user can test the application inside an isolated Kubernetes cluster.
139+
2. **Deploy the application**: Deploy the application Helm chart on the vCluster just created.
142140

143141
After the completion of all steps, you can check the correct status of every step:
144142

145143
![CD workflow graph](images/4_cd_graph.png)
146144

147-
If all steps have been completed, you can check the status of your application deployed on the vCluster just created
148-
149145
### 10. Access to the application
150146

151147
To check how to access the application deployed on vCluster, you can run these commands to list all vCluster and to access it:
@@ -157,24 +153,18 @@ $ vcluster list
157153
------------------+----------+-----------------+---------+---------+-----------+-------------------------------+---------+---------
158154
demo-pr-request | minikube | demo-pr-request | Running | 0.19.0 | | xxxx-xx-xx xx:xx:xx +0100 CET | 1h8m49s | OSS
159155

160-
$ vcluster connect demo-pr-request --namespace demo-pr-request -- kubectl get pod -n demo-pr-request
156+
$ vcluster connect demo-pr-request --namespace demo-pr-request -- kubectl get pod -n demo-pr-request
161157

162158
NAME READY STATUS RESTARTS AGE
163159
demo-pr-request-hello-world-7f6d78645f-bjmjc 1/1 Running 0 7s
164160
```
165161

166-
As reported [here](https://www.vcluster.com/docs/using-vclusters/access) you can expose in different ways the ephemeral vCluster created.
167-
168-
- **Via Ingress**: An Ingress Controller with SSL passthrough support will provide the best user experience, but there is a workaround if this feature is not natively supported.
169-
170-
- Kubernetes Nginx
171-
- Traefik Proxy
172-
- Emissary
162+
As reported [here](https://www.vcluster.com/docs/using-vclusters/access), you can expose the ephemeral vCluster created differently.
173163

174-
Make sure your ingress controller is installed and healthy on the cluster that will host your virtual clusters. More details [here](https://www.vcluster.com/docs/using-vclusters/access#via-ingress)
164+
- **Via Ingress**: An Ingress Controller with SSL passthrough support will provide the best user experience. Ensure your ingress controller is installed and healthy on the cluster hosting your virtual clusters. More details [here](https://www.vcluster.com/docs/using-vclusters/access#via-ingress)
175165
- **Via LoadBalancer service**: The easiest way is to use the flag `--expose` in vcluster create to tell vCluster to use a LoadBalancer service. It depends on the specific implementation of the host Kubernetes cluster.
176-
- **Via NodePort service**: You can also expose the vCluster via a NodePort service. In this case, you have to create a NodePort service and change the `values.yaml` file to use for the creation of the vCluster. More details [here](https://www.vcluster.com/docs/using-vclusters/access#via-nodeport-service)
177-
- **From Host **Cluster**: To access the virtual cluster from within the host cluster, you can directly connect to the vCluster service. Make sure you can access that service and then create a kube config in the following form:
166+
- **Via NodePort service**: You can also expose the vCluster via a NodePort service. In this case, you must create a NodePort service and change the `values.yaml` file to use for the creation of the vCluster. More details [here](https://www.vcluster.com/docs/using-vclusters/access#via-nodeport-service)
167+
- **From Host Cluster**: To access the virtual cluster from within the host cluster, you can directly connect to the vCluster service. Make sure you can access that service and then create a kube config in the following form:
178168

179169
```bash
180170
vcluster connect my-vcluster -n my-vcluster --server=my-vcluster.my-vcluster --insecure --update-current=false

argo/README.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)