mirror of
https://github.com/prometheus-operator/kube-prometheus.git
synced 2025-10-23 05:01:02 +02:00
Merge pull request #1415 from ArthurSens/as/codespace-workspaces
Better ephemeral workspace support with Codespaces
This commit is contained in:
commit
167caa3bd7
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,4 +5,5 @@ vendor/
|
|||||||
.swp
|
.swp
|
||||||
crdschemas/
|
crdschemas/
|
||||||
|
|
||||||
.gitpod/_output/
|
developer-workspace/gitpod/_output
|
||||||
|
kind
|
@ -24,17 +24,17 @@ tasks:
|
|||||||
chmod +x ${PWD}/.git/hooks/pre-commit
|
chmod +x ${PWD}/.git/hooks/pre-commit
|
||||||
- name: run kube-prometheus
|
- name: run kube-prometheus
|
||||||
command: |
|
command: |
|
||||||
.gitpod/prepare-k3s.sh
|
developer-workspace/gitpod/prepare-k3s.sh
|
||||||
.gitpod/deploy-kube-prometheus.sh
|
developer-workspace/common/deploy-kube-prometheus.sh
|
||||||
- name: kernel dev environment
|
- name: kernel dev environment
|
||||||
init: |
|
init: |
|
||||||
sudo apt update -y
|
sudo apt update -y
|
||||||
sudo apt install qemu qemu-system-x86 linux-image-$(uname -r) libguestfs-tools sshpass netcat -y
|
sudo apt install qemu qemu-system-x86 linux-image-$(uname -r) libguestfs-tools sshpass netcat -y
|
||||||
sudo curl -o /usr/bin/kubectl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
sudo curl -o /usr/bin/kubectl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
sudo chmod +x /usr/bin/kubectl
|
sudo chmod +x /usr/bin/kubectl
|
||||||
.gitpod/prepare-rootfs.sh
|
developer-workspace/gitpod/prepare-rootfs.sh
|
||||||
command: |
|
command: |
|
||||||
.gitpod/qemu.sh
|
developer-workspace/gitpod/qemu.sh
|
||||||
ports:
|
ports:
|
||||||
- port: 3000
|
- port: 3000
|
||||||
onOpen: open-browser
|
onOpen: open-browser
|
||||||
|
5
Makefile
5
Makefile
@ -78,3 +78,8 @@ $(BIN_DIR):
|
|||||||
$(TOOLING): $(BIN_DIR)
|
$(TOOLING): $(BIN_DIR)
|
||||||
@echo Installing tools from scripts/tools.go
|
@echo Installing tools from scripts/tools.go
|
||||||
@cd scripts && cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go build -modfile=go.mod -o $(BIN_DIR) %
|
@cd scripts && cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go build -modfile=go.mod -o $(BIN_DIR) %
|
||||||
|
|
||||||
|
.PHONY: deploy
|
||||||
|
deploy:
|
||||||
|
./developer-workspace/codespaces/prepare-kind.sh
|
||||||
|
./developer-workspace/common/deploy-kube-prometheus.sh
|
||||||
|
34
developer-workspace/README.md
Normal file
34
developer-workspace/README.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Ephemeral developer workspaces
|
||||||
|
|
||||||
|
Aiming to provide better developer experience when making contributions to kube-prometheus, whether by actively developing new features/bug fixes or by reviewing pull requests, we want to provide ephemeral developer workspaces with everything already configured (as far as tooling makes it possible).
|
||||||
|
|
||||||
|
Those developer workspaces should provide a brand new kubernetes cluster, where kube-prometheus can be easily deployed and the contributor can easily see the impact that a pull request is proposing.
|
||||||
|
|
||||||
|
Today there is 2 providers in the market:
|
||||||
|
* [Github Codespaces](https://github.com/features/codespaces)
|
||||||
|
* [Gitpod](https://www.gitpod.io/)
|
||||||
|
|
||||||
|
## Codespaces
|
||||||
|
|
||||||
|
Unfortunately, Codespaces is not available for everyone. If you are fortunate to have access to it, you can open a new workspace from a specific branch, or even from Pull Requests.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
After your workspace start, you can deploy a kube-prometheus inside a Kind cluster inside by running `make deploy`.
|
||||||
|
|
||||||
|
If you are reviewing a PR, you'll have a fully-functional kubernetes cluster, generating real monitoring data that can be used to review if the proposed changes works as described.
|
||||||
|
|
||||||
|
If you are working on new features/bug fixes, you can regenerate kube-prometheus's YAML manifests with `make generate` and deploy it again with `make deploy`.
|
||||||
|
|
||||||
|
## Gitpod
|
||||||
|
|
||||||
|
Gitpod is already available to everyone to use for free. It can also run commands that we speficy in the `.gitpod.yml` file located in the root directory of the git repository, so even the cluster creation can be fully automated.
|
||||||
|
|
||||||
|
You can use the same workflow as mentioned in the [Codespaces](#Codespaces) section, however Gitpod doesn't have native support for any kubernetes distribution. The workaround is to create a full QEMU Virtual Machine and deploy [k3s](https://github.com/k3s-io/k3s) inside this VM. Don't worry, this whole process is already fully automated, but due to the workaround the whole workspace may be very slow.
|
||||||
|
|
||||||
|
To open up a workspace with Gitpod, you can install the [Google Chrome extension](https://www.gitpod.io/docs/browser-extension/) to add a new button to Github UI and use it on PRs or from the main page. Or by directly typing in the browser `http://gitpod.io/#https://github.com/prometheus-operator/kube-prometheus/pull/<Pull Request Number>` or just `http://gitpod.io/#https://github.com/prometheus-operator/kube-prometheus`
|
||||||
|
|
||||||
|

|
||||||
|
|
20
developer-workspace/codespaces/prepare-kind.sh
Executable file
20
developer-workspace/codespaces/prepare-kind.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
which kind
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
echo 'kind not available in $PATH, installing latest kind'
|
||||||
|
# Install latest kind
|
||||||
|
curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest \
|
||||||
|
| grep "browser_download_url.*kind-linux-amd64" \
|
||||||
|
| cut -d : -f 2,3 \
|
||||||
|
| tr -d \" \
|
||||||
|
| wget -qi -
|
||||||
|
mv kind-linux-amd64 kind && chmod +x kind
|
||||||
|
fi
|
||||||
|
|
||||||
|
cluster_created=$($PWD/kind get clusters 2>&1)
|
||||||
|
if [[ "$cluster_created" == "No kind clusters found." ]]; then
|
||||||
|
$PWD/kind create cluster
|
||||||
|
else
|
||||||
|
echo "Cluster '$cluster_created' already present"
|
||||||
|
fi
|
@ -1,9 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
kubectl apply -f manifests/setup
|
kubectl apply -f manifests/setup
|
||||||
|
|
||||||
# Safety wait for CRDs to be working
|
# Safety wait for CRDs to be working
|
||||||
sleep 30
|
sleep 30
|
||||||
|
|
||||||
kubectl apply -f manifests/
|
kubectl apply -f manifests/
|
||||||
|
sleep 30
|
||||||
|
# Safety wait for resources to be created
|
||||||
|
|
||||||
kubectl rollout status -n monitoring daemonset node-exporter
|
kubectl rollout status -n monitoring daemonset node-exporter
|
||||||
kubectl rollout status -n monitoring statefulset alertmanager-main
|
kubectl rollout status -n monitoring statefulset alertmanager-main
|
Loading…
x
Reference in New Issue
Block a user