Skip to content

Commit

Permalink
feat(kind-test-environment): update to use nginx-ingress
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Marshall <alex@blockchaintp.com>
  • Loading branch information
alexhq authored and scealiontach committed Jun 27, 2022
1 parent 8528ef4 commit 11607f1
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions bash/kind-test-environment
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
#!/bin/bash
#!/usr/bin/env bash

# Example kind config for a 4 node cluster:
## kind: Cluster
## name: test
## apiVersion: kind.x-k8s.io/v1alpha4
## networking:
## apiServerAddress: 0.0.0.0
## apiServerPort: 6443
## nodes:
## - role: control-plane
## kubeadmConfigPatches:
## - |
## kind: InitConfiguration
## nodeRegistration:
## kubeletExtraArgs:
## node-labels: "ingress-ready=true"
## extraPortMappings:
## - containerPort: 80
## hostPort: 80
## listenAddress: "0.0.0.0"
## - containerPort: 443
## hostPort: 443
## listenAddress: "0.0.0.0"
## - role: worker
## - role: worker
## - role: worker
## - role: worker

# shellcheck source=includer.sh
source "$(dirname "${BASH_SOURCE[0]}")/includer.sh"
Expand All @@ -14,20 +41,13 @@ function ::add_ns {
ADDITIONAL_NAMESPACES="$ADDITIONAL_NAMESPACES,$ns"
}

function ::use_dind {
docker run -d --privileged -p 2375:2375 -p 6443:6443 -e DOCKER_TLS_CERTDIR="" \
docker:dind --tls=false
DOCKER_HOST=tcp://localhost:2375
}

ADD_HELM_REPOS+=("openebs,https://openebs.github.io/charts/")
ADD_HELM_REPOS+=("bitnami,https://charts.bitnami.com/bitnami")
ADD_HELM_REPOS+=("emissary-ingress,https://app.getambassador.io")

log::level 2
options::standard
options::description "This script creates a kind cluster suitable for testing"
options::add -o n -d "then name of the kind cluster to create" -a -e CLUSTER_NAME
options::add -o n -d "the name of the kind cluster to create" -a -e CLUSTER_NAME
options::add -o f -d "kind config file" -a -m -e KIND_CONFIG
options::add -o c -d "command: create, delete" -a -m -e COMMAND
options::add -o t -d "namespaces to add" -a -f ::add_ns
Expand Down Expand Up @@ -127,10 +147,7 @@ function ::asdf {
$_asdf local "$plugin" "$version"
return $?
}
kubectl create secret generic regcred \
-n "$ns" \
"--from-file=.dockerconfigjson=$HOME/.docker/config.json" \
--type=kubernetes.io/dockerconfigjson 2>/dev/null || true

function kind::preflight {
::ensure_asdf
::asdf kind
Expand Down Expand Up @@ -184,12 +201,7 @@ function ::add_storage_provider {
}

function ::add_ingress_provider {
## WIP
kubectl apply -f https://projectcontour.io/quickstart/contour.yaml
kubectl patch daemonsets -n projectcontour envoy \
-p '{"spec":{"template":{"spec":{"nodeSelector":{"ingress-ready":"true"},
"tolerations":[{"key":"node-role.kubernetes.io/master","operator":"Equal",
"effect":"NoSchedule"}]}}}}'
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
}

function create {
Expand All @@ -205,11 +217,11 @@ function create {
}

function delete {
set -e
# set -e
kind::preflight
kind::delete "$CLUSTER_NAME"
::delete_dind
set +e
# set +e
}

"$COMMAND"

0 comments on commit 11607f1

Please sign in to comment.