diff --git a/dev/kind-config.yaml b/dev/kind-config.yaml new file mode 100644 index 0000000..18eb9ae --- /dev/null +++ b/dev/kind-config.yaml @@ -0,0 +1,2 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 diff --git a/environments/helm-controller/devspace.yaml b/environments/helm-controller/devspace.yaml new file mode 100644 index 0000000..66d7f99 --- /dev/null +++ b/environments/helm-controller/devspace.yaml @@ -0,0 +1,7 @@ +version: v1beta11 + +commands: + - name: "install" + command: |- + kubectl apply -f manifests/deploy-namespaced.yaml + until kubectl wait --for=condition=available deployment/helm-controller -n kube-system --timeout=60s 2>/dev/null; do echo -n "." && sleep 2; done diff --git a/environments/helm-controller/manifests/deploy-namespaced.yaml b/environments/helm-controller/manifests/deploy-namespaced.yaml new file mode 100644 index 0000000..b17a53e --- /dev/null +++ b/environments/helm-controller/manifests/deploy-namespaced.yaml @@ -0,0 +1,76 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: helmcharts.helm.cattle.io + namespace: kube-system +spec: + group: helm.cattle.io + version: v1 + names: + kind: HelmChart + plural: helmcharts + singular: helmchart + scope: Namespaced +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: helm-controller + namespace: kube-system + labels: + app: helm-controller +spec: + replicas: 1 + selector: + matchLabels: + app: helm-controller + template: + metadata: + labels: + app: helm-controller + spec: + serviceAccount: helm-controller + containers: + - name: helm-controller + image: rancher/helm-controller:v0.2.2 + command: ["helm-controller"] + args: ["--namespace", "helm-controller"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + annotations: + rbac.authorization.kubernetes.io/autoupdate: "true" + labels: + kubernetes.io/bootstrapping: rbac-defaults + name: helm-controller +rules: + - apiGroups: + - "*" + resources: + - "*" + verbs: + - "*" + - nonResourceURLs: + - "*" + verbs: + - "*" +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + namespace: kube-system + name: helm-controller +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: helm-controller +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: helm-controller +subjects: + - apiGroup: rbac.authorization.k8s.io + kind: User + name: system:serviceaccount:kube-system:helm-controller diff --git a/environments/kind/README.md b/environments/kind/README.md new file mode 100644 index 0000000..d7f3cc8 --- /dev/null +++ b/environments/kind/README.md @@ -0,0 +1,56 @@ +# kind devspace environment + +Setup and manage kind cluster instance's for local development. +This is currently the preferred way of running clusters over k3d or minikube. + +* Cluster with predefined or self-defined configuration + +Predefined cluster configurations are located in `config`-folder and can be +used by setting `KIND_CLUSTER_CONFIG`. + +## Deployments + +-none- + +## Commands + +### `activate` + +Configure kubernetes context etc. to point to this cluster. +Needs to be called when switch from another environment back +to an already initialized environment. + +### `purge` + +Deletes the kind cluster resources (except container registry). + +### `init` + +Creates kind registry and custer, and calls `devspace run activate`. + +## Variables + +### `KIND_CLUSTER_NAME` + +Name of the cluster to create. +default: `devspace-base` + +### `KIND_CLUSTER_CONFIG` + +Filepath to kind cluster config yaml to use for creation. +default: `./config/minimal-cluster.yaml` + +Attention: Using local path like `./config/minimal-cluster.yaml` points +to devspace folder of `kind`, not to the devspace-folder in your environment. +Currently didn't find a clean way to use folder in derived devspace +environments. So you need to add new configs into config folder from +`devspace.base`. + +### `KIND_CLUSTER_VERSION` + +Version of the kubernets cluster. +default: `v1.21.12` + +## Profiles + +-none- diff --git a/environments/kind/devspace.yaml b/environments/kind/devspace.yaml new file mode 100644 index 0000000..314d699 --- /dev/null +++ b/environments/kind/devspace.yaml @@ -0,0 +1,32 @@ +version: v1beta11 + +vars: + - name: KIND_CLUSTER_NAME + source: env + - name: KIND_CONFIG + source: env + - name: KIND_CLUSTER_VERSION + source: env + default: "v1.21.12" + +commands: + - name: activate + description: Configure environment to point to this cluster. + command: |- + kubectl config use-context kind-${KIND_CLUSTER_NAME} + kubectl config set-context --current --namespace ${KIND_CLUSTER_NAME} + - name: purge + description: Delete cluster resources. + command: |- + kind delete cluster --name ${KIND_CLUSTER_NAME} + kubectl config delete-context kind-${KIND_CLUSTER_NAME} 2>/dev/null || true + kubectl config delete-cluster kind-${KIND_CLUSTER_NAME} 2>/dev/null || true + kubectl config delete-user kind-${KIND_CLUSTER_NAME} 2>/dev/null || true + - name: init + description: Setup registry, custer and activate environment. + command: |- + set -e + kind create cluster --name ${KIND_CLUSTER_NAME} --image kindest/node:${KIND_CLUSTER_VERSION} --config ${KIND_CONFIG} + export KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME} + export KIND_CONFIG=${KIND_CONFIG} + devspace run activate diff --git a/environments/minikube/README.md b/environments/minikube/README.md new file mode 100644 index 0000000..7c89ff5 --- /dev/null +++ b/environments/minikube/README.md @@ -0,0 +1,43 @@ +# minikube devspace environment + +Setup and manage minikube cluster instance's for local development. + +* Cluster with predefined or self-defined configuration + +Predefined cluster configurations are located in `config`-folder and can be +used by setting `minikube_CLUSTER_CONFIG`. + +## Deployments + +-none- + +## Commands + +### `activate` + +Configure kubernetes context etc. to point to this cluster. +Needs to be called when switch from another environment back +to an already initialized environment. + +### `purge` + +Deletes the minikube cluster resources. + +### `init` + +Creates minikube registry and custer, and calls `devspace run activate`. + +## Variables + +### `MINIKUBE_CLUSTER_NAME` + +Name of the cluster to create. +default: `devspace-base` + +### `MINIKUBE_EXTRA_ARGS` + +Extra args for minikube. Run `minikube start --help` for possible arguments + +## Profiles + +-none- diff --git a/environments/minikube/devspace.yaml b/environments/minikube/devspace.yaml new file mode 100644 index 0000000..997966d --- /dev/null +++ b/environments/minikube/devspace.yaml @@ -0,0 +1,26 @@ +version: v1beta11 + +vars: + - name: MINIKUBE_CLUSTER_NAME + source: env + - name: MINIKUBE_EXTRA_ARGS + source: env + default: "" + +commands: + - name: activate + description: Configure environment to point to this cluster. + command: |- + kubectl config use-context ${MINIKUBE_CLUSTER_NAME} + kubectl config set-context --current --namespace ${MINIKUBE_CLUSTER_NAME} + + - name: purge + description: Delete cluster resources (except container registry). + command: |- + minikube delete -p ${MINIKUBE_CLUSTER_NAME} + rm ~/.kube/config-${MINIKUBE_CLUSTER_NAME} + + - name: init + description: Setup registry, custer and activate environment. + command: |- + minikube start -p ${MINIKUBE_CLUSTER_NAME} ${MINIKUBE_EXTRA_ARGS}