Skip to content

Commit

Permalink
chore: 🧑‍💻 add development environement script
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-tobi committed Aug 16, 2024
1 parent d3c0c74 commit ee00d81
Show file tree
Hide file tree
Showing 10 changed files with 381 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.github/
ci/
kind/
.release-please-manifest.json
release-please-manifest.json
README.md
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Dev stage
FROM --platform=${BUILDPLATFORM:-linux/amd64} docker.io/golang:1.22.4 AS dev

RUN go install github.com/air-verse/air@latest
WORKDIR /go/src/app
COPY go.mod go.mod
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ domainFilters: ["subzone.d1.dev.example.com"]
provider:
name: webhook
webhook:
image: ghcr.io/titigmr/external-dns-midaas-webhook
tag: latest
image:
repository: ghcr.io/titigmr/external-dns-midaas-webhook
tag: latest
env:
- name: PROVIDER_DNS_ZONE_SUFFIX
value: "dev.example.com"
Expand Down
30 changes: 30 additions & 0 deletions kind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Run kubernetes locally with docker

## Prerequisite

Download & install on your local machine :
- [kind](https://github.com/kubernetes-sigs/kind)
- [kubectl](https://github.com/kubernetes/kubectl)
- [helm](https://github.com/helm/helm)

## Commands

```sh
# Start kind cluster
sh ./run.sh -c create

# Build and load docker-compose images into the cluster
sh ./run.sh -c build

# Stop kind cluster
sh ./run.sh -c delete

# Start kind cluster, build and load images and deploy app
sh ./run.sh -c dev
```

## Cluster

One single node is deployed but it can be customized in `./configs/kind-config.yml`. The cluster comes with [Traefik](https://doc.traefik.io/traefik/providers/kubernetes-ingress/) ingress controller installed with port mapping on both ports `80` and `443`.

The node is using `extraMounts` to provide a volume binding between host working directory and `/app` to give the ability to bind mount volumes into containers during development.
21 changes: 21 additions & 0 deletions kind/configs/kind-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
extraMounts:
- hostPath: ./
containerPath: /app
19 changes: 19 additions & 0 deletions kind/configs/traefik-values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
providers:
kubernetesCRD:
namespaces:
- default
- ingress-traefik
kubernetesIngress:
namespaces:
- default
- ingress-traefik

ports:
web:
nodePort: 80
websecure:
nodePort: 443

service:
type: NodePort
7 changes: 7 additions & 0 deletions kind/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
server:
image: external-dns-midaas-webhook:dev
build:
context: ..
dockerfile: ./Dockerfile
target: dev
37 changes: 37 additions & 0 deletions kind/resources/external-dns-values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -- How DNS records are synchronized between sources and providers; available values are `sync` & `upsert-only`.
policy: sync
# -- Specify the registry for storing ownership and labels.
# Valid values are `txt`, `aws-sd`, `dynamodb` & `noop`.
# If `noop` midaas manage all records on zone
registry: txt
# can restrict zone
provider:
name: webhook
webhook:
image:
repository: external-dns-midaas-webhook
tag: dev
pullPolicy: Never
env:
- name: TSIG_ZONE_foo
value: bar
- name: API_LOG_LEVEL
value: DEBUG
- name: PROVIDER_SKIP_TLS_VERIFY
value: "true"
extraVolumeMounts:
- name: dev-workspace
mountPath: /go/src/app
env:
- name: PROVIDER_DNS_ZONE_SUFFIX
value: "dev.example.com"
- name: PROVIDER_WS_URL
value: https://midaas.example.com/midaas/ws"
- name: TSIG_ZONE_foo
value: foo
podSecurityContext:
runAsNonRoot: false
extraVolumes:
- name: dev-workspace
hostPath:
path: /app
17 changes: 17 additions & 0 deletions kind/resources/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test
spec:
rules:
- host: test.foo.dev.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: test
port:
number: 8080
Loading

0 comments on commit ee00d81

Please sign in to comment.