feat: initial commit
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
data
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# Run Unbound environment in local K8S
|
||||||
|
|
||||||
|
This is a setup for running the Unbound environment in K8S using [KinD](https://kind.sigs.k8s.io/)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- [KinD](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
|
||||||
|
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
|
||||||
|
|
||||||
|
## Creating the cluster
|
||||||
|
|
||||||
|
Just run the following:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./setup
|
||||||
|
```
|
||||||
|
|
||||||
|
Wait for the cluster to be ready. The K8S context should be set automatically. Check what's been deployed by running:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
kubectl get pod -A
|
||||||
|
```
|
||||||
|
|
||||||
|
## Stopping/starting the cluster
|
||||||
|
|
||||||
|
If you need to stop the cluster to be able to use the exposed ports for other things, run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker stop unbound-control-plane
|
||||||
|
```
|
||||||
|
|
||||||
|
To start it again:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker start unbound-control-plane
|
||||||
|
```
|
||||||
|
|
||||||
|
## Removing the cluster
|
||||||
|
|
||||||
|
To remove the cluster completely, run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
kind delete cluster --name unbound
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cleaning up retained data
|
||||||
|
|
||||||
|
The setup stores data for containers in the `data`-directory. To start from scratch, stop the cluster, empty the directory
|
||||||
|
and start the cluster again.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
kind: Cluster
|
||||||
|
apiVersion: kind.x-k8s.io/v1alpha4
|
||||||
|
name: unbound
|
||||||
|
nodes:
|
||||||
|
- role: control-plane
|
||||||
|
kubeadmConfigPatches:
|
||||||
|
- |
|
||||||
|
kind: InitConfiguration
|
||||||
|
nodeRegistration:
|
||||||
|
kubeletExtraArgs:
|
||||||
|
node-labels: "ingress-ready=true"
|
||||||
|
- |
|
||||||
|
kind: ClusterConfiguration
|
||||||
|
apiServer:
|
||||||
|
extraArgs:
|
||||||
|
service-node-port-range: 3000-39999
|
||||||
|
extraPortMappings:
|
||||||
|
- containerPort: 80
|
||||||
|
hostPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 443
|
||||||
|
hostPort: 443
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 5672
|
||||||
|
hostPort: 5672
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 15672
|
||||||
|
hostPort: 15672
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 3306
|
||||||
|
hostPort: 3306
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 5432
|
||||||
|
hostPort: 5432
|
||||||
|
protocol: TCP
|
||||||
|
extraMounts:
|
||||||
|
- hostPath: ./data
|
||||||
|
containerPath: /data
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- mysql.yaml
|
||||||
|
- postgres.yaml
|
||||||
|
- rabbitmq.yaml
|
||||||
|
- https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
|
||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: mysql
|
||||||
|
stringData:
|
||||||
|
DB_HOST: mysql
|
||||||
|
DB_PORT: "3306"
|
||||||
|
DB_NAME: mysql
|
||||||
|
DB_USER: mysql
|
||||||
|
DB_PASSWORD: mysql
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: mysql
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: mysql
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: mysql
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: mysql:8
|
||||||
|
name: mysql
|
||||||
|
env:
|
||||||
|
- name: MYSQL_ROOT_PASSWORD
|
||||||
|
value: password
|
||||||
|
ports:
|
||||||
|
- containerPort: 3306
|
||||||
|
name: mysql
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/mysql
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
hostPath:
|
||||||
|
path: /data/mysql
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: mysql
|
||||||
|
name: mysql
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: mysql
|
||||||
|
port: 3306
|
||||||
|
nodePort: 3306
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
app: mysql
|
||||||
|
sessionAffinity: None
|
||||||
|
type: NodePort
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
kind: ConfigMap
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: shared-postgres
|
||||||
|
data:
|
||||||
|
DB_HOST: "postgres-postgresql"
|
||||||
|
DB_PORT: "5432"
|
||||||
|
DB_USER: "postgres"
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: postgres
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: postgres
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: postgres
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: postgres:12.0
|
||||||
|
imagePullPolicy: "IfNotPresent"
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: 200Mi
|
||||||
|
limits:
|
||||||
|
memory: 300Mi
|
||||||
|
ports:
|
||||||
|
- containerPort: 5432
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
value: postgres
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
value: postgres
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
value: postgres
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
hostPath:
|
||||||
|
path: /data/postgres
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: postgres
|
||||||
|
labels:
|
||||||
|
app: postgres
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 5432
|
||||||
|
nodePort: 5432
|
||||||
|
selector:
|
||||||
|
app: postgres
|
||||||
|
type: NodePort
|
||||||
+138
@@ -0,0 +1,138 @@
|
|||||||
|
kind: ConfigMap
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: shared-rabbitmq
|
||||||
|
data:
|
||||||
|
RABBITMQ_SERVERS: rabbitmq
|
||||||
|
RABBITMQ_VHOST: /
|
||||||
|
RABBITMQ_USERNAME: user
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: rabbitmq
|
||||||
|
release: rabbitmq
|
||||||
|
name: rabbitmq
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: rabbitmq
|
||||||
|
strategy:
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 1
|
||||||
|
maxUnavailable: 1
|
||||||
|
type: RollingUpdate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: rabbitmq
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: RABBITMQ_DEFAULT_USER
|
||||||
|
value: user
|
||||||
|
- name: RABBITMQ_DEFAULT_PASS
|
||||||
|
value: password
|
||||||
|
- name: RABBITMQ_NODE_PORT_NUMBER
|
||||||
|
value: "5672"
|
||||||
|
- name: RABBITMQ_NODE_TYPE
|
||||||
|
value: stats
|
||||||
|
- name: RABBITMQ_NODENAME
|
||||||
|
value: rabbit@localhost
|
||||||
|
- name: RABBITMQ_CLUSTER_NODE_NAME
|
||||||
|
- name: RABBITMQ_DEFAULT_VHOST
|
||||||
|
value: /
|
||||||
|
- name: RABBITMQ_MANAGER_PORT_NUMBER
|
||||||
|
value: "15672"
|
||||||
|
- name: RABBITMQ_DISK_FREE_LIMIT
|
||||||
|
value: '"8GiB"'
|
||||||
|
image: sparetimecoders/rabbitmq:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
livenessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- rabbitmqctl
|
||||||
|
- status
|
||||||
|
failureThreshold: 6
|
||||||
|
initialDelaySeconds: 120
|
||||||
|
periodSeconds: 10
|
||||||
|
successThreshold: 1
|
||||||
|
timeoutSeconds: 5
|
||||||
|
name: rabbitmq
|
||||||
|
ports:
|
||||||
|
- containerPort: 4369
|
||||||
|
name: epmd
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 5672
|
||||||
|
name: amqp
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 25672
|
||||||
|
name: dist
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 15672
|
||||||
|
name: stats
|
||||||
|
protocol: TCP
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- rabbitmqctl
|
||||||
|
- status
|
||||||
|
failureThreshold: 3
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 5
|
||||||
|
successThreshold: 1
|
||||||
|
timeoutSeconds: 3
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 256Mi
|
||||||
|
terminationMessagePath: /dev/termination-log
|
||||||
|
terminationMessagePolicy: File
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/rabbitmq
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
hostPath:
|
||||||
|
path: /data/rabbitmq
|
||||||
|
dnsPolicy: ClusterFirst
|
||||||
|
restartPolicy: Always
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: rabbitmq
|
||||||
|
release: rabbitmq
|
||||||
|
name: rabbitmq
|
||||||
|
spec:
|
||||||
|
externalTrafficPolicy: Cluster
|
||||||
|
ports:
|
||||||
|
- name: epmd
|
||||||
|
nodePort: 31799
|
||||||
|
port: 4369
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: epmd
|
||||||
|
- name: amqp
|
||||||
|
nodePort: 5672
|
||||||
|
port: 5672
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: amqp
|
||||||
|
- name: dist
|
||||||
|
nodePort: 32687
|
||||||
|
port: 25672
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: dist
|
||||||
|
- name: stats
|
||||||
|
nodePort: 15672
|
||||||
|
port: 15672
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: stats
|
||||||
|
selector:
|
||||||
|
app: rabbitmq
|
||||||
|
sessionAffinity: None
|
||||||
|
type: NodePort
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
kind create cluster --config kind.yaml --wait 10m
|
||||||
|
|
||||||
|
kubectl create secret docker-registry gitlab \
|
||||||
|
--docker-server=registry.gitlab.com \
|
||||||
|
--docker-username=gitlab \
|
||||||
|
--docker-password="${GITLAB_TOKEN}" \
|
||||||
|
--docker-email=gitlab@paidit.se
|
||||||
|
|
||||||
|
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gitlab"}]}'
|
||||||
|
|
||||||
|
kubectl apply -k .
|
||||||
Reference in New Issue
Block a user