From eab4ca3ec13097845fa258431df0b8bb141af8f1 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Tue, 13 Jun 2023 16:19:38 +0200 Subject: [PATCH] feat(docker): adding k8s compatible Dockerfile --- README.md | 52 ++++++++++++++++++- misc/images/app-kube/Dockerfile | 3 ++ misc/k8s/kind/cluster/kustomization.yaml | 11 ++++ misc/k8s/kind/cluster/lb/kustomization.yaml | 7 +++ .../kind/cluster/lb/resources/advertise.yaml | 9 ++++ .../cluster/lb/resources/ipaddresspoool.yaml | 8 +++ misc/k8s/kind/kind-cluster.yaml | 48 +++++++++++++++++ 7 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 misc/k8s/kind/cluster/kustomization.yaml create mode 100644 misc/k8s/kind/cluster/lb/kustomization.yaml create mode 100644 misc/k8s/kind/cluster/lb/resources/advertise.yaml create mode 100644 misc/k8s/kind/cluster/lb/resources/ipaddresspoool.yaml create mode 100644 misc/k8s/kind/kind-cluster.yaml diff --git a/README.md b/README.md index 0d72778..7ddb019 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,55 @@ Symfony Skeletor +# Create a dev cluster with "kind" + + +1. Start your Kubernetes cluster + + ```shell + export ENGINE="kind" + ``` + + Setup your "harbor" user: + ``` + export HARBOR_USER_NAME="" + ``` + + Create the cluster + + ```shell + ${ENGINE} create cluster --config misc/k8s/${ENGINE}/${ENGINE}-cluster.yaml + ``` + +2. Check your cluster status + + ```shell + kubectl get nodes + ``` + All the nodes are "Ready" + ``` + NAME STATUS ROLES AGE VERSION + dev-control-plane Ready control-plane 5d5h v1.27.2 + dev-worker Ready 5d5h v1.27.2 + dev-worker2 Ready 5d5h v1.27.2 + dev-worker3 Ready 5d5h v1.27.2 + ``` + +3. Déployer les opérateurs dans votre cluster + + ```shell + kubectl apply -k misc/k8s/${ENGINE}/cluster --server-side + ``` + +4. Récupèrer la plage IP de votre "cluster" + Si vous utilisez [kind](https://kind.sigs.k8s.io) : + + ```shell + docker network inspect kind | jq '.[0].IPAM.Config[0].Subnet' -r + ``` + En toute logique vous devriez obtenir un résultat du type `172.XX.0.0/16`. + Gardez cette information pour plus tard. + + ``` your-project/ ├── assets/ @@ -20,4 +70,4 @@ your-project/ ├── translations/ ├── var/ └── vendor/ -``` \ No newline at end of file +``` diff --git a/misc/images/app-kube/Dockerfile b/misc/images/app-kube/Dockerfile index e69de29..e8ca857 100644 --- a/misc/images/app-kube/Dockerfile +++ b/misc/images/app-kube/Dockerfile @@ -0,0 +1,3 @@ +ARG ADDITIONAL_PACKAGES="tree" + +FROM reg.cadoles.com/cadoles/symfony:alpine-php-8.1-base diff --git a/misc/k8s/kind/cluster/kustomization.yaml b/misc/k8s/kind/cluster/kustomization.yaml new file mode 100644 index 0000000..f499bad --- /dev/null +++ b/misc/k8s/kind/cluster/kustomization.yaml @@ -0,0 +1,11 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- https://raw.githubusercontent.com/ory/k8s/v0.30.0/helm/charts/hydra-maester/crds/crd-oauth2clients.yaml +- https://forge.cadoles.com/CadolesKube/c-kustom//base/cloudnative-pg-operator?ref=develop +- https://forge.cadoles.com/CadolesKube/c-kustom//base/redis?ref=develop +- https://forge.cadoles.com/CadolesKube/c-kustom//base/minio?ref=develop +- https://forge.cadoles.com/CadolesKube/c-kustom//base/metallb?ref=develop +- https://forge.cadoles.com/CadolesKube/c-kustom//base/metrics?ref=develop +- https://forge.cadoles.com/CadolesKube/c-kustom//base/nginx?ref=develop diff --git a/misc/k8s/kind/cluster/lb/kustomization.yaml b/misc/k8s/kind/cluster/lb/kustomization.yaml new file mode 100644 index 0000000..6446c8b --- /dev/null +++ b/misc/k8s/kind/cluster/lb/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: metallb-system + +resources: +- ./resources/ipaddresspoool.yaml +- ./resources/advertise.yaml diff --git a/misc/k8s/kind/cluster/lb/resources/advertise.yaml b/misc/k8s/kind/cluster/lb/resources/advertise.yaml new file mode 100644 index 0000000..d251dba --- /dev/null +++ b/misc/k8s/kind/cluster/lb/resources/advertise.yaml @@ -0,0 +1,9 @@ +apiVersion: metallb.io/v1beta1 +kind: L2Advertisement +metadata: + name: l2-ip-pool-ad + namespace: metallb-system +spec: + ipAddressPools: + - main-pool + diff --git a/misc/k8s/kind/cluster/lb/resources/ipaddresspoool.yaml b/misc/k8s/kind/cluster/lb/resources/ipaddresspoool.yaml new file mode 100644 index 0000000..da37f87 --- /dev/null +++ b/misc/k8s/kind/cluster/lb/resources/ipaddresspoool.yaml @@ -0,0 +1,8 @@ +apiVersion: metallb.io/v1beta1 +kind: IPAddressPool +metadata: + name: main-pool + namespace: metallb-system +spec: + addresses: + - 172.18.10.100-172.18.10.200 diff --git a/misc/k8s/kind/kind-cluster.yaml b/misc/k8s/kind/kind-cluster.yaml new file mode 100644 index 0000000..5ac7351 --- /dev/null +++ b/misc/k8s/kind/kind-cluster.yaml @@ -0,0 +1,48 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +name: mse-dev +networking: + podSubnet: "10.110.0.0/16" + serviceSubnet: "10.115.0.0/16" +nodes: +- role: control-plane + image: kindest/node:v1.27.2 + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 31000 + hostPort: 31000 + listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0" + - containerPort: 80 + hostPort: 8080 + listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0" + labels: + ingress-ready: true +- role: worker + image: kindest/node:v1.27.2 + kubeadmConfigPatches: + - | + kind: JoinConfiguration + nodeRegistration: + kubeletExtraArgs: + system-reserved: memory=2Gi +- role: worker + image: kindest/node:v1.27.2 + kubeadmConfigPatches: + - | + kind: JoinConfiguration + nodeRegistration: + kubeletExtraArgs: + system-reserved: memory=2Gi +- role: worker + image: kindest/node:v1.27.2 + kubeadmConfigPatches: + - | + kind: JoinConfiguration + nodeRegistration: + kubeletExtraArgs: + system-reserved: memory=2Gi