Skip to content

Commit f24f211

Browse files
committed
Updating the readme to be less RKO focused
1 parent 775861a commit f24f211

File tree

2 files changed

+69
-58
lines changed

2 files changed

+69
-58
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ jobs:
5353
- name: build and push website container
5454
working-directory: src
5555
run: |
56-
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 -f "./RandomQuotes.Web/Dockerfile" --tag octopussamples/randomquotes-k8s:${{ steps.determine_version.outputs.semVer }} --tag octopussamples/randomquotes-k8s:latest .
56+
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 -f "./RandomQuotes.Web/Dockerfile" --tag ${{ secrets.DOCKERHUB_REPO }}:${{ env.GitVersion_SemVer }} --tag ${{ secrets.DOCKERHUB_REPO }}:latest .

Readme.md

Lines changed: 68 additions & 57 deletions
Original file line numberDiff line numberDiff 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.
22

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:
4+
5+
- [Pods](https://kubernetes.io/docs/concepts/workloads/pods/)
6+
- [ReplicaSets](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/)
7+
- [Kubernetes Deployment Object](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)
8+
- [Environment Variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/)
9+
- [Secrets](https://kubernetes.io/docs/concepts/configuration/secret/)
10+
- [Namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
11+
- [Ingress Controllers](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/)
12+
- [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/)
13+
14+
# GitHub Action and Docker Repository
15+
16+
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
437

538
# Prep Work
639

40+
If you are using this repository to learn about kubernetes, you can follow the steps and activities below.
41+
742
The docker image, manifest files, and variables will be provided to you. You need to provide a k8s cluster, octopus instance, and worker.
843

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.
1046

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!
1348

1449
- [docker desktop](https://docs.docker.com/desktop/) - easiest and preferred
1550
- 🍎 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!
2358
Open up a command prompt or terminal. Change the current directory in the terminal to the `k8s/provision` folder in this repo.
2459
- Run the following commands:
2560
- 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.
2861
- 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.
3162

3263
## 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:
3465

3566
- Create a worker pool name "Local K8s Worker Pool".
3667
- 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.
4469
- Go to Library -> Feeds
4570
- Add a docker hub feed
4671
- 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.
5473
- Use the Local K8s Worker Pool from earlier.
5574
- Assign it to all four environments from earlier.
5675
- 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`
5976
- Go to Library -> Git Credentials.
6077
- Add a new GitHub PAT token for your user.
6178
- The PAT will need explict access to OctopusSamples.
@@ -65,7 +82,7 @@ Using your cloud instance of choice do the following:
6582
- Username will be your username.
6683

6784
## 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.
6986

7087
```
7188
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
7592
127.0.0.1 randomquotesprod.local
7693
```
7794

78-
## 5. Install Argo
95+
# Activities
7996

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.
9798

9899
## 1. First Activity - Basic Deployment
99100

@@ -109,7 +110,7 @@ These instructions will deploy the following to the default namespace.
109110
- Ingress Rule
110111

111112
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.
113114
- Open up a command prompt or terminal. Change the current directory in the terminal to the `k8s/base` folder in this repo.
114115
- Run `kubectl apply -f randomquotes-secrets.yaml`
115116
- 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
162163
- Go to the deployment process
163164
- Add a DEPLOY RAW KUBERNETES YAML
164165
- 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
168167
- Role: Use the role from your k8s cluster
169168
- YAML Source: Git Repository
170169
- Git Credentials: Use the git credentials from the library
171-
- Repository URL: https://github.com/OctopusSamples/RandomQuotes-K8s.git
170+
- Repository URL: https://github.com/[YOUR USER OR ORG]/RandomQuotes-K8s.git
172171
- Branch Settings: main
173172
- Paths: k8s/base/randomquotes-secrets.yaml
174173
- Structured Configuration Values: Check the `Enable Structured Configuration Variables` checkbox
175174
- Namespace: #{Octopus.Environment.Name | ToLower}
176175
- Add a DEPLOY RAW KUBERNETES YAML
177176
- Name: Deploy Random Quotes
178-
- Worker Pool: Use the Local K8s Worker Pool
179-
- **If you are running the tentacle in a container**
180-
- Update the health check to use an execution container. For the image use `octopuslabs/k8s-workertools:1.29.0`
177+
- Worker Pool: Since you are running the agent, this shouldn't matter
181178
- Role: Use the role from your k8s cluster
182179
- YAML Source: Git Repository
183180
- Git Credentials: Use the git credentials from the library
184-
- Repository URL: https://github.com/OctopusSamples/RandomQuotes-K8s.git
181+
- Repository URL: https://github.com/[YOUR USER OR ORG]/RandomQuotes-K8s.git
185182
- Branch Settings: main
186183
- Paths: k8s/base/randomquotes-deployment.yaml
187184
- Structured Configuration Valures: Check the `Enable Structured Configuration Variables` checkbox
188185
- Referenced Packages:
189186
- Package Feed: DockerHub
190-
- PackageId: octopussamples/randomquotes-k8s
187+
- PackageId: [octopussamples | REPLACE octopussamples with your user]/randomquotes-k8s
191188
- Name: randomquotes-k8s
192189
- Namespace: #{Octopus.Environment.Name | ToLower}
193190
- Save the deployment process
194191
- Create a release and deploy it to dev.
195192
- Test by going to randomquotesdev.local.
196193
- Promote the release through each environment. Test along the way.
197194

198-
## 4. Fourth Activity - ArgoCD
195+
## 4. Fourth Activity - ArgoCD - Optional!
199196

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"))`
201212

202213
- Configure first application
203214
- Click the `New App` button

0 commit comments

Comments
 (0)