Setup a Kubernetes Developer Cluster using
kind
ork3d
running in GitHub Codespaces
GitHub Codespaces is currently in preview
- Fork this repo and use your fork to run GitHub Codespaces
- Click the
Code
button on the forked repo - Click
Open with Codespaces
- Click
New Codespace
- When prompted, choose
Open Workspace
By default the solution will create a kind
cluster. If you want to use k3d export the K8S
environment variable
# (optional) set makefile to use k3d
export K8S=k3d
- From the Codespaces terminal
- ensure you are in the
~/workspaces/akdc-kind
directory make all
- ensure you are in the
Output from make all
should resemble this
default fluentb 1/1 Running 0 31s
default jumpbox 1/1 Running 0 25s
default loderunner 1/1 Running 0 31s
default ngsa-memory 1/1 Running 0 33s
monitoring grafana-64f7dbcf96-cfmtd 1/1 Running 0 32s
monitoring prometheus-deployment-67cbf97f84-tjxm7 1/1 Running 0 32s
# curl all of the endpoints
{ "apiVersion": "1.0", "appVersion": "0.1.1-0210-0338", "language": "C#" }
0.1.1-0210-0537
<a href="/graph">Found</a>.
<a href="/login">Found</a>.
- From the Codespace terminal window, start
k9s
- Type
k9s
and press enter - Press
0
to select all namespaces - Wait for all pods to be in the
Running
state (look for theSTATUS
column) - Use the arrow key to select
nsga-memory
then press thel
key to view logs from the pod - To go back, press the
esc
key - To view other deployed resources - press
shift + :
followed by the deployment type (e.g.secret
,services
,deployment
, etc). - To exit -
:q <enter>
- Type
- All endpoints are usable in your browser via clicking on the
Ports (4)
tab- Select the
open in browser icon
on the far right
- Select the
- Some popup blockers block the new browser tab
- If you get a gateway error, just hit refresh - it will clear once the port-forward is ready
# check endpoints
make check
Open curl.http
curl.http is used in conjuction with the Visual Studio Code REST Client extension.
When you open curl.http, you should see a clickable
Send Request
text above each of the URLs
Clicking on Send Request
should open a new panel in Visual Studio Code with the response from that request like so:
A jump box
pod is created so that you can execute commands in the cluster
- use the
kje
aliaskubectl exec -it jumpbox --
- examples
- run http against the ClusterIP
kje http ngsa-memory:8080/version
- run an interactive shell
kje bash -l
- note: -l causes a login and processes
.profile
- note:
sh -l
will work, but the results will not be displayed in the terminal
- note: -l causes a login and processes
- run http against the ClusterIP
-
Grafana login info
- admin
- Ngsa512
-
Once
make all
completes successfully- Click on the
ports
tab of the terminal window - Click on the
open in browser icon
on the Grafana port (32000) - This will open Grafana in a new browser tab
- Click on the
- Click on
Home
at the top of the page - From the dashboards page, click on
NGSA
# from Codespaces terminal
make load-test
- Switch to the Grafana brower tab
- The test will generate 400 / 404 results
- The requests metric will go from green to yellow to red as load increases
- It may skip yellow
- As the test completes
- The metric will go back to green (1.0)
- The request graph will return to normal
-
Click on the
ports
tab of the terminal window -
Click on the
open in browser icon
on the Prometheus port (30000) -
This will open Prometheus in a new browser tab
-
From the Prometheus tab
- Begin typing NgsaAppDuration_bucket in the
Expression
search - Click
Execute
- This will display the
histogram
that Grafana uses for the charts
- Begin typing NgsaAppDuration_bucket in the
- Start
k9s
from the Codespace terminal - Select
fluentb
and pressenter
- Press
enter
again to see the logs - Press
s
to Toggle AutoScroll - Press
w
to Toggle Wrap - Review logs that will be sent to Log Analytics when configured
- Switch back to your Codespaces tab
# from Codespaces terminal
# make and deploy a local version of LodeRunner to k8s
make loderunner
- Switch back to your Codespaces tab
# from Codespaces terminal
# make and deploy a local version of ngsa-memory to k8s
make app
Makefile is a good place to start exploring
Question: Why don't we use helm to deploy Kubernetes manifests?
Answer: The purpose of this repository is to get developers up and running, with all dependencies install and deployed, so they can focus on writing code. The target audience for this repository is the app developers who do not necessary care about how their app is deployed.
Leaving the manifests as is rather than converting them to helm has the added benefit of readability so if a developer did want to see how their app is deployed or if they need to make modifications to the deployment, it is a lot easier to do so.
In saying that, we do have helm installed inside the .devcontainer
to make it easy to deploy additional dependencies to the cluster in future.