dynatrace-oss / progressiveDelivery-masterclass

Apache License 2.0
4 stars 11 forks source link

Adding Codespaces Capability #72

Closed heckelmann closed 1 year ago

heckelmann commented 1 year ago

This PR adds everything needed to run this demo in GitHub Codepaces

agardnerIT commented 1 year ago

Spin up of codespace works on a cloud codespace. Doesn't work (see below) on local Windows codespace (perhaps it's Windows?).

klt-config tasks error even on cloud. when I try to delete those resources:

Unable to delete resource: ServiceMonitor monitoring.coreos.com klt-metrics-server not found as part of application klt-config
Unable to delete resource: KeptnConfig options.keptn.sh keptnconfig-sample not found as part of application klt-config
Unable to delete resource: grpc: error while marshaling: proto: required field "version" not set

I start this on my machine (in local VSCode) and see:

[474992 ms] Start: Run in container: cat /proc/1132/environ
[568913 ms] Port forwarding connection from 57679 > 34977 > 34977 in the container.
[568914 ms] Start: Run in container: /home/vscode/.vscode-server/bin/2ccd690cbff1569e4a83d7c43d45101f817401dc/node -e 
[568915 ms] Port forwarding connection from 57680 > 34977 > 34977 in the container.
[568916 ms] Start: Run in container: /home/vscode/.vscode-server/bin/2ccd690cbff1569e4a83d7c43d45101f817401dc/node -e 
[569169 ms] Port forwarding connection from 57682 > 34977 > 34977 in the container.
[569170 ms] Start: Run in container: /home/vscode/.vscode-server/bin/2ccd690cbff1569e4a83d7c43d45101f817401dc/node -e 
[569207 ms] Port forwarding 57679 > 34977 > 34977 stderr: Connection established
[569251 ms] Port forwarding 57680 > 34977 > 34977 stderr: Connection established
[569476 ms] Port forwarding 57682 > 34977 > 34977 stderr: Connection established
[572498 ms] Port forwarding 57679 > 34977 > 34977: Local close
[572517 ms] Port forwarding 57679 > 34977 > 34977 stderr: Remote stdin close
[572557 ms] Port forwarding 57679 > 34977 > 34977 terminated by extension (closed) with code 0 and signal null.
[572997 ms] Port forwarding 57680 > 34977 > 34977: Local close
[573000 ms] Port forwarding 57682 > 34977 > 34977: Local close
[573014 ms] Port forwarding 57680 > 34977 > 34977 stderr: Remote stdin close
[573015 ms] Port forwarding 57682 > 34977 > 34977 stderr: Remote stdin close
[573053 ms] Port forwarding 57682 > 34977 > 34977 terminated by extension (closed) with code 0 and signal null.
[573057 ms] Port forwarding 57680 > 34977 > 34977 terminated by extension (closed) with code 0 and signal null.

It just hangs here so I open another terminal and I see it drops me into the devcontainer.

Read the readme and it tells me to do make create:

vscode ➜ /workspaces/progressivedelivery-masterclass (feature-codespaces) $ make create
Creating Kind cluster
Creating cluster "demo-cluster" ...
 ✓ Ensuring node image (kindest/node:v1.27.3) đŸ–ŧ
 ✓ Preparing nodes đŸ“Ļ  
 ✓ Writing configuration 📜 
 ✓ Starting control-plane 🕹ī¸ 
 ✗ Installing CNI 🔌 
Deleted nodes: ["demo-cluster-control-plane"]
ERROR: failed to create cluster: failed to apply overlay network: command "docker exec --privileged -i demo-cluster-control-plane kubectl create --kubeconfig=/etc/kubernetes/admin.conf -f -" failed with error: exit status 1
Command Output: The connection to the server demo-cluster-control-plane:6443 was refused - did you specify the right host or port?
make: *** [Makefile:13: create] Error 1

Changing devcontainer username from vscode to root as described here didn't work:

// some base images require a specific user name
//"remoteUser": "vscode",
"remoteUser": "root",
$ make create
Creating Kind cluster
Creating cluster "demo-cluster" ...
 ✓ Ensuring node image (kindest/node:v1.27.3) đŸ–ŧ
 ✓ Preparing nodes đŸ“Ļ  
 ✓ Writing configuration 📜 
 ✗ Starting control-plane 🕹ī¸ 
Deleted nodes: ["demo-cluster-control-plane"]
ERROR: failed to create cluster: failed to remove control plane taint: command "docker exec --privileged demo-cluster-control-plane kubectl --kubeconfig=/etc/kubernetes/admin.conf taint nodes --all node-role.kubernetes.io/control-plane-" failed with error: exit status 1
Command Output: E0728 04:37:17.738393     283 memcache.go:265] couldn't get current server API group list: Get "https://demo-cluster-control-plane:6443/api?timeout=32s": dial tcp 172.18.0.2:6443: connect: connection refused
E0728 04:37:17.739143     283 memcache.go:265] couldn't get current server API group list: Get "https://demo-cluster-control-plane:6443/api?timeout=32s": dial tcp 172.18.0.2:6443: connect: connection refused
The connection to the server demo-cluster-control-plane:6443 was refused - did you specify the right host or port?
make: *** [Makefile:13: create] Error 1

Documentation

Notes for when we update docs:

Do not F5 refresh the codespace. It will reload the codespace and lose progress.

  1. Tell user to fork the repo
  2. (Temporarily until this PR is merged) untick the "fork only main branch" so user has access to feature-codespaces
  3. (Temporarily until this PR is merged) In the users fork on Github.com, change branch to feature-codespaces
  4. When codespace starts, first do a find and replace in the browser. Find aloisreitbauer/progressivedelivery-masterclass Replace with: username/progressivedelivery-masterclass eg. agardnerit/progressivedelivery-masterclass Replace all
  5. Commit changes back to Git: git add -A git commit -m "move to my repo" git push
  6. (Temporarily until this PR is merged): Do a find and replace to change the branch reference. Find: targetRevision: main Replace: targetRevision: feature-codespaces
  7. (Temporarily until this PR is merged) Commit changes back to Git: git add -A git commit -m "change branch" git push
  8. Run git status to verify it says:
    
    On branch feature-codespaces
    Your branch is up to date with 'origin/feature-codespaces'.

nothing to commit, working tree clean


10. `make create`
11. At this point, explain what is happening.
They should see lots of output, starting with:

$ make create Creating Kind cluster Creating cluster "demo-cluster" ... ✓ Ensuring node image (kindest/node:v1.27.3) đŸ–ŧ ✓ Preparing nodes đŸ“Ļ
✓ Writing configuration 📜 ✓ Starting control-plane 🕹ī¸ ✓ Installing CNI 🔌 ✓ Installing StorageClass 💾 Set kubectl context to "kind-demo-cluster" You can now use your cluster with:

kubectl cluster-info --context kind-demo-cluster

Have a nice day! 👋 Deploy ArgoCD



and ending with a random looking string.

This is the argocd password. They should copy this to their clipboard. The `%` at the end of the password is NOT part of the password (can we add a newline char to make this clearer?)

12. Change to the Ports tab in cloud vscode and open Argo. If they need it again:
    `kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo` (the user will get a browser warning that they must Allow).
Argo username = admin

13. They will see lots of applications being deployed. Wait until `progressive-delivery-masterclass`  is green (it will take a little while - if face to face, present or explain some concepts here).

14.

--------------

When 
---------------

## Random thoughts

- An architecture diagram would be great to visually see what's going on
- I don't think we can rely on people installing the `gh` CLI
- Do we need an "instructors guide" for those delivering this to an audience?
heckelmann commented 1 year ago

Spin up of codespace works on a cloud codespace. Doesn't work (see below) on local Windows codespace (perhaps it's Windows?).

The initial intention for this was not to run it locally, but I added a fix. At least it is working now on my local machine. I needed to change the network settings in the run args "runArgs": ["--init", "--privileged", "--network=host"],

Documentation

Notes for when we update docs:

Do not F5 refresh the codespace. It will reload the codespace and lose progress.

Really? I could even close my browser and then return to my codespace.

I don't think we can rely on people installing the gh CLI

Unfortunately, this is the only way to access Grafana. Using the forwarded codespaces port, which is using an nginx as a reverse proxy the CORS check is failing.