add support for developing in-cluster with Skaffold (#27)

This commit is contained in:
Michael Vorburger ⛑️ 2021-11-20 19:16:56 +01:00 committed by GitHub
parent 520d0c79da
commit 6bf14043bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 0 deletions

View File

@ -161,6 +161,19 @@ docker run -it --rm \
go build ./cmd/mc-router go build ./cmd/mc-router
``` ```
## Skaffold
For "in-cluster development" it's convenient to use https://skaffold.dev. Any changes to Go source code
will trigger a go build, new container image pushed to registry with a new tag, and refresh in Kubernetes
with the image tag used in the deployment transparently updated to the new tag and thus new pod created pulling new images:
skaffold dev
When using Google Cloud (GCP), first create a _Docker Artifact Registry_,
then add the _Artifact Registry Reader_ Role to the _Compute Engine default service account_ of your GKE clusterService Account_ (to avoid error like "container mc-router is waiting to start: ...-docker.pkg.dev/... can't be pulled"),
then use e.g. `gcloud auth configure-docker europe-docker.pkg.dev` or equivalent one time (to create a `~/.docker/config.json`),
and then use e.g. `--default-repo=europe-docker.pkg.dev/YOUR-PROJECT/YOUR-ARTIFACT-REGISTRY` option for `skaffold dev`.
## Performing snapshot release with Docker ## Performing snapshot release with Docker
```bash ```bash

35
docs/k8s-deployment.yaml Normal file
View File

@ -0,0 +1,35 @@
# used by ../skaffold.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: mc-router
name: mc-router
spec:
selector:
matchLabels:
run: mc-router
strategy:
type: Recreate
template:
metadata:
labels:
run: mc-router
spec:
serviceAccountName: mc-router
containers:
- image: itzg/mc-router:latest
name: mc-router
args: ["--api-binding", ":8080", "--in-kube-cluster"]
ports:
- name: proxy
containerPort: 25565
- name: web
containerPort: 8080
resources:
requests:
memory: 50Mi
cpu: "100m"
limits:
memory: 100Mi
cpu: "250m"

14
skaffold.yaml Normal file
View File

@ -0,0 +1,14 @@
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: mc-router
build:
artifacts:
- image: itzg/mc-router
# https://skaffold.dev/docs/pipeline-stages/builders/ko/
ko:
main: ./cmd/mc-router/
deploy:
kubectl:
manifests:
- docs/k8s-deployment.yaml