You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+68-57Lines changed: 68 additions & 57 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,50 @@
1
-
This is a sample application deploy to Kubernetes. It's a good first application as it has no other components, but has an environment variable you can use to practice secrets on.
1
+
This is a sample application deploy to Kubernetes. It's a good first application as it has no other components, but it is simple and can be easily modified.
2
2
3
-
The docker image is built using a GitHub action and it is pushed to Docker Hub. You can find the docker repository here: https://hub.docker.com/r/octopussamples/randomquotes-k8s/tags
3
+
Configuring Kubernetes to host this particular container will teach you the following:
The Docker Container is built using a GitHub action and it is pushed to Docker Hub. Both a Linux/x86 and Linux/arm64 image are built.
17
+
18
+
You can find the docker repository here: https://hub.docker.com/r/octopussamples/randomquotes-k8s/tags
19
+
20
+
# Forking this repo
21
+
22
+
Feel free to fork the repo for your own K8s testing and learning. A few quick notes:
23
+
24
+
- The primary build is found in `.github/workflows/build.yml`
25
+
- The DockerFile is found in `.src/RandomQuotes.Web` - it injects the version from the build into the container itself.
26
+
- All the Kubernetes items are found in the `k8s` folder.
27
+
- Base - contains all the basic configuration.
28
+
- Overlays - Kustomize overlays, one for each environment.
29
+
- Charts - The Helm chart.
30
+
- Provision - The core manifest files used to provision a new cluster.
31
+
32
+
If you fork this repo you will need to set the following repo secrets:
33
+
34
+
-`DOCKERHUB_PAT_USERNAME` - your username
35
+
-`DOCKERHUB_PAT` - the PAT of your user
36
+
-`DOCKERHUB_REPO` - the docker hub repo to store the container - this really isn't a secret, but I made it one so you wouldn't have to modify the build
4
37
5
38
# Prep Work
6
39
40
+
If you are using this repository to learn about kubernetes, you can follow the steps and activities below.
41
+
7
42
The docker image, manifest files, and variables will be provided to you. You need to provide a k8s cluster, octopus instance, and worker.
8
43
9
-
**You MUST finish all the prep work prior to RKO. We will not wait for you to install K8s, configure a worker, or update your hosts file.**
44
+
## 1. Install / Create K8s Cluster
45
+
Setup a K8s cluster in Azure, GCP, or AWS. Be forewarned, AWS IAM policies often make it the most difficult K8s implementation to use.
10
46
11
-
## 1. Install K8s
12
-
Install ONE of the following on a VM or locally!
47
+
Optionally, You can install ONE of the following on a VM or locally for free!
13
48
14
49
-[docker desktop](https://docs.docker.com/desktop/) - easiest and preferred
15
50
- 🍎 If you are working on a Mac with an Apple chip—Docker Desktop is the easiest option:
@@ -23,39 +58,21 @@ Install ONE of the following on a VM or locally!
23
58
Open up a command prompt or terminal. Change the current directory in the terminal to the `k8s/provision` folder in this repo.
24
59
- Run the following commands:
25
60
- Create all the namespaces: `kubectl apply -f namespaces.yaml`
26
-
- Create the service account for deployments: `kubectl apply -f service-account-and-token.yaml`
27
-
- To get the token value run: `kubectl describe secret octopus-svc-account-token`. Copy the token to a file for future usage.
28
61
- Install the NGINX Ingress Controller: `kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.9.5/deploy/static/provider/cloud/deploy.yaml`
29
-
- If you are running rancher desktop or minikube
30
-
- Run `kubectl describe service kubernetes`. Copy the endpoint, for example `172.18.135.254:6443` for later.
31
62
32
63
## 3. Pre-Configure Octopus
33
-
Using your cloud instance of choice do the following:
64
+
Using your Octopus Deploy cloud instance of choice do the following:
34
65
35
66
- Create a worker pool name "Local K8s Worker Pool".
36
67
- Ensure you have the following environments: "Development", "Test", "Staging", "Production"
37
-
- Install a tentacle to connect to Octopus Deploy
38
-
- Option A: Install a polling tentacle directly on your machine (preferred and easiest).
39
-
- Option B: Run the tentacle as a docker container. A custom image with kubectl has been pre-created. Run `docker run --env ServerApiKey=YOUR_API_KEY --env ServerUrl=YOUR_SERVER_URL --env Space=Default --env TargetWorkerPool="Local K8s Worker Pool" --env ACCEPT_EULA=Y --env DISABLE_DIND=N --env ServerPort=10943 --env TargetName="Docker Worker" --platform linux/amd64 mcasperson/tentacle`
40
-
- Option C: Run the tentacle from Kubernetes.
41
-
- In a file explorer, go to `octopus-tentacle.yaml` file and replace `YOUR_API_KEY` and `YOUR_SERVER_URL` with your API key and server URL.
42
-
- Run `kubectl apply -f octopus-tentacle.yaml`
43
-
- WAIT until the worker shows up as healthy in your Local K8s Worker Pool.
68
+
- Install the kubernetes agent on your K8s cluster.
44
69
- Go to Library -> Feeds
45
70
- Add a docker hub feed
46
71
- Provide your username and PAT or a service account username and PAT otherwise you won't be able to create releases.
47
-
- Go to Infrastructure -> Accounts. Add the token from the earlier step.
48
-
- Go to Infrastructure -> Targets. Add the kubernetes cluster.
49
-
- If you are using docker desktop it should be: `https://kubernetes.docker.internal:6443/`
50
-
- If you are running rancher desktop or minikube:
51
-
- Use the endpoint IP address from earlier. For example `https://172.18.135.254:6443`
52
-
- Ensure the checkbox `Skip TLS Verification` is checked to make things easier.
53
-
- Use the token account you created from earlier.
72
+
- Go to Infrastructure -> Targets. Add the kubernetes cluster using the agent.
54
73
- Use the Local K8s Worker Pool from earlier.
55
74
- Assign it to all four environments from earlier.
56
75
- Use the role `local-k8s`.
57
-
-**If you are running the tentacle in a container**
58
-
- Update the health check to use an execution container. For the image use `octopuslabs/k8s-workertools:1.29.0`
59
76
- Go to Library -> Git Credentials.
60
77
- Add a new GitHub PAT token for your user.
61
78
- The PAT will need explict access to OctopusSamples.
@@ -65,7 +82,7 @@ Using your cloud instance of choice do the following:
65
82
- Username will be your username.
66
83
67
84
## 4. Configure your hosts file.
68
-
Go to your hosts file (if on Windows) and add the following entries. The nginx ingress controller uses host headers for all routing. Doing this will allow you to easily access the application running on your k8s cluster.
85
+
Go to your hosts file (if running the K8s cluster on Windows locally) and add the following entries. The nginx ingress controller uses host headers for all routing. Doing this will allow you to easily access the application running on your k8s cluster.
69
86
70
87
```
71
88
127.0.0.1 randomquotes.local
@@ -75,25 +92,9 @@ Go to your hosts file (if on Windows) and add the following entries. The nginx
75
92
127.0.0.1 randomquotesprod.local
76
93
```
77
94
78
-
## 5. Install Argo
95
+
#Activities
79
96
80
-
This will install ArgoCD on your cluster. Perfect for poking around!
81
-
82
-
- Install ArgoCD
83
-
- Run `kubectl create namespace argocd`
84
-
- Run `kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml`
85
-
- To access ArgoCD UI
86
-
- Run `kubectl port-forward svc/argocd-server -n argocd 8080:443`
87
-
-**Important** The port forwarding will only work while that window is open.
88
-
- If you want to, you can mess with ingress rules, but this is the quick and dirty approach to getting going.
89
-
- To login
90
-
- Username is admin
91
-
- Run `kubectl get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' --namespace argocd` to get the password.
92
-
- Please note it is base64, which you will need to decode. You can do that via an online editor, or PowerShell `[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("blahblahblah"))`
93
-
94
-
# 200 Session at RKO
95
-
96
-
All the activities below will be done at RKO.
97
+
All the activities below will be done to help teach K8s deployments.
97
98
98
99
## 1. First Activity - Basic Deployment
99
100
@@ -109,7 +110,7 @@ These instructions will deploy the following to the default namespace.
109
110
- Ingress Rule
110
111
111
112
To perform the deployment do the following:
112
-
- Go to https://hub.docker.com/r/octopussamples/randomquotes-k8s/tags and find the latest version tag (0.1.3 for example). Update the `image` entry in the randomquotes-deployment.yaml file.
113
+
- Go to https://hub.docker.com/r/octopussamples (or your repo)/randomquotes-k8s/tags and find the latest version tag (0.1.3 for example). Update the `image` entry in the randomquotes-deployment.yaml file.
113
114
- Open up a command prompt or terminal. Change the current directory in the terminal to the `k8s/base` folder in this repo.
114
115
- Run `kubectl apply -f randomquotes-secrets.yaml`
115
116
- Run `kubectl apply -f randomquotes-deployment.yaml`
@@ -162,42 +163,52 @@ In this example, we will put the kustomize overlays aside and instead use Octopu
162
163
- Go to the deployment process
163
164
- Add a DEPLOY RAW KUBERNETES YAML
164
165
- Name: Create Random Quotes Secret
165
-
- Worker Pool: Use the Local K8s Worker Pool
166
-
- **If you are running the tentacle in a container**
167
-
- Update the health check to use an execution container. For the image use `octopuslabs/k8s-workertools:1.29.0`
166
+
- Worker Pool: Since you are running the agent, this shouldn't matter
168
167
- Role: Use the role from your k8s cluster
169
168
- YAML Source: Git Repository
170
169
- Git Credentials: Use the git credentials from the library
- Promote the release through each environment. Test along the way.
197
194
198
-
## 4. Fourth Activity - ArgoCD
195
+
## 4. Fourth Activity - ArgoCD - Optional!
199
196
200
-
This activity will happen only if we have enough time. We will install and configure ArgoCD so we can compare and contrast the two.
197
+
If you wish to learn ArgoCD, you can perform these steps.
198
+
199
+
First install ArgoCD on the cluster.
200
+
201
+
- Install ArgoCD
202
+
- Run `kubectl create namespace argocd`
203
+
- Run `kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml`
204
+
- To access ArgoCD UI
205
+
- Run `kubectl port-forward svc/argocd-server -n argocd 8080:443`
206
+
-**Important** The port forwarding will only work while that window is open.
207
+
- If you want to, you can mess with ingress rules, but this is the quick and dirty approach to getting going.
208
+
- To login
209
+
- Username is admin
210
+
- Run `kubectl get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' --namespace argocd` to get the password.
211
+
- Please note it is base64, which you will need to decode. You can do that via an online editor, or PowerShell `[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("blahblahblah"))`
0 commit comments