Remove minikube and only use kind (#5059)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-02-12 20:19:57 -03:00 committed by GitHub
parent 281139d1a7
commit 0365a7c172
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 81 additions and 58 deletions

View file

@ -22,10 +22,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
NAMESPACE="${NAMESPACE:-ingress-nginx}" DIR=$(cd $(dirname "${BASH_SOURCE}") && pwd -P)
echo "NAMESPACE is set to ${NAMESPACE}"
kubectl config use-context minikube
export TAG=dev export TAG=dev
export ARCH=amd64 export ARCH=amd64
@ -33,46 +30,66 @@ export REGISTRY=${REGISTRY:-ingress-controller}
DEV_IMAGE=${REGISTRY}/nginx-ingress-controller:${TAG} DEV_IMAGE=${REGISTRY}/nginx-ingress-controller:${TAG}
{ [ "$(minikube status | grep -c Running)" -ge 2 ] && minikube status | grep -qE ': Configured$|Correctly Configured'; } \ kind --version || $(echo "Please install kind.";exit 1)
|| minikube start \
--extra-config=kubelet.sync-frequency=1s \
--extra-config=apiserver.authorization-mode=RBAC
# shellcheck disable=SC2046 KUBE_CLIENT_VERSION=$(kubectl version --client --short | awk '{print $3}' | cut -d. -f2) || true
eval $(minikube docker-env --shell bash) if [[ ${KUBE_CLIENT_VERSION} -lt 14 ]]; then
echo "[dev-env] Please update kubectl to 1.15 or higher"
fi
echo "[dev-env] building container" echo "[dev-env] building container"
make build container make build container
docker tag "${REGISTRY}/nginx-ingress-controller-${ARCH}:${TAG}" "${DEV_IMAGE}" docker tag "${REGISTRY}/nginx-ingress-controller-${ARCH}:${TAG}" "${DEV_IMAGE}"
# kubectl >= 1.14 includes Kustomize via "apply -k". Makes it easier to use on Linux as well, assuming kubectl installed export K8S_VERSION=${K8S_VERSION:-v1.17.2@sha256:59df31fc61d1da5f46e8a61ef612fa53d3f9140f82419d1ef1a6b9656c6b737c}
KUBE_CLIENT_VERSION=$(kubectl version --client --short | awk '{print $3}' | cut -d. -f2) || true
if [[ ${KUBE_CLIENT_VERSION} -lt 14 ]]; then
for tool in kubectl kustomize; do
echo "[dev-env] installing $tool"
$tool version || brew install $tool
done
fi
if ! kubectl get namespace "${NAMESPACE}"; then export DOCKER_CLI_EXPERIMENTAL=enabled
kubectl create namespace "${NAMESPACE}"
fi
kubectl get deploy nginx-ingress-controller -n "${NAMESPACE}" && kubectl delete deploy nginx-ingress-controller -n "${NAMESPACE}" KIND_CLUSTER_NAME="ingress-nginx-dev"
ROOT=./deploy/minikube if ! kind get clusters -q | grep -q ${KIND_CLUSTER_NAME}; then
echo "[dev-env] creating Kubernetes cluster with kind"
if [[ ${KUBE_CLIENT_VERSION} -lt 14 ]]; then cat <<EOF | kind create cluster --name ${KIND_CLUSTER_NAME} --config=-
pushd $ROOT kind: Cluster
kustomize edit set namespace "${NAMESPACE}" apiVersion: kind.x-k8s.io/v1alpha4
kustomize edit set image "quay.io/kubernetes-ingress-controller/nginx-ingress-controller=${DEV_IMAGE}" nodes:
popd - role: control-plane
kubeadmConfigPatches:
echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE" - |
kustomize build $ROOT | kubectl apply -f - kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
authorization-mode: "AlwaysAllow"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
EOF
else else
sed -i -e "s|^namespace: .*|namespace: ${NAMESPACE}|g" "${ROOT}/kustomization.yaml" echo "[dev-env] using existing Kubernetes kind cluster"
echo "[dev-env] deploying NGINX Ingress controller in namespace $NAMESPACE"
kubectl apply -k "${ROOT}"
fi fi
echo "[dev-env] copying docker images to cluster..."
kind load docker-image --name="${KIND_CLUSTER_NAME}" "${DEV_IMAGE}"
echo "[dev-env] deploying NGINX Ingress controller..."
kubectl create namespace ingress-nginx || true
kubectl apply -k ${DIR}/../deploy/kind
echo "[dev-env] deleting old ingress-nginx pods..."
kubectl get pods --namespace ingress-nginx -o go-template \
--template '{{range .items}}{{.metadata.name}} {{.metadata.creationTimestamp}}{{"\n"}}{{end}}' | \
awk '$2 <= "'$(date -d'now-1 minute' -Ins --utc | sed 's/+0000/Z/')'" { print $1 }' | \
xargs --no-run-if-empty kubectl delete pod --namespace ingress-nginx
cat <<EOF
Kubernetes cluster ready and ingress-nginx listening in localhost using ports 80 and 443
To delete the dev cluster execute: 'kind delete cluster --name ingress-nginx-dev'
EOF

View file

@ -45,13 +45,6 @@ FLAGS=$@
PKG=k8s.io/ingress-nginx PKG=k8s.io/ingress-nginx
ARCH=$(go env GOARCH) ARCH=$(go env GOARCH)
MINIKUBE_PATH=${HOME}/.minikube
MINIKUBE_VOLUME="-v ${MINIKUBE_PATH}:${MINIKUBE_PATH}"
if [ ! -d "${MINIKUBE_PATH}" ]; then
echo "Minikube directory not found! Volume will be excluded from docker build."
MINIKUBE_VOLUME=""
fi
# create output directory as current user to avoid problem with docker. # create output directory as current user to avoid problem with docker.
mkdir -p "${KUBE_ROOT}/bin" "${KUBE_ROOT}/bin/${ARCH}" mkdir -p "${KUBE_ROOT}/bin" "${KUBE_ROOT}/bin/${ARCH}"
@ -67,7 +60,6 @@ docker run \
-v "${KUBE_ROOT}/bin/${ARCH}:/go/bin/linux_${ARCH}" \ -v "${KUBE_ROOT}/bin/${ARCH}:/go/bin/linux_${ARCH}" \
-v "/var/run/docker.sock:/var/run/docker.sock" \ -v "/var/run/docker.sock:/var/run/docker.sock" \
-v "${INGRESS_VOLUME}:/etc/ingress-controller/" \ -v "${INGRESS_VOLUME}:/etc/ingress-controller/" \
${MINIKUBE_VOLUME} \
-w "/go/src/${PKG}" \ -w "/go/src/${PKG}" \
-u $(id -u ${USER}):$(id -g ${USER}) \ -u $(id -u ${USER}):$(id -g ${USER}) \
${E2E_IMAGE} /bin/bash -c "${FLAGS}" ${E2E_IMAGE} /bin/bash -c "${FLAGS}"

View file

@ -94,11 +94,6 @@ until curl --output /dev/null -fsSL http://localhost:8001/; do
sleep 5 sleep 5
done done
MINIKUBE_VOLUME=
if [[ -d "${HOME}/.minikube" ]]; then
MINIKUBE_VOLUME=" -v ${HOME}/.minikube:${HOME}/.minikube "
fi
# if we run as user we cannot bind to port 80 and 443 # if we run as user we cannot bind to port 80 and 443
docker run \ docker run \
--rm \ --rm \
@ -109,7 +104,6 @@ docker run \
-e POD_NAME="${POD_NAME}" \ -e POD_NAME="${POD_NAME}" \
-v "${SSL_VOLUME}:/etc/ingress-controller/ssl/" \ -v "${SSL_VOLUME}:/etc/ingress-controller/ssl/" \
-v "${HOME}/.kube:${HOME}/.kube:ro" \ -v "${HOME}/.kube:${HOME}/.kube:ro" \
${MINIKUBE_VOLUME} \
"${IMAGE}-${ARCH}:${TAG}" /nginx-ingress-controller \ "${IMAGE}-${ARCH}:${TAG}" /nginx-ingress-controller \
--update-status=false \ --update-status=false \
--v=2 \ --v=2 \

View file

@ -7,3 +7,5 @@ bases:
images: images:
- name: quay.io/kubernetes-ingress-controller/nginx-ingress-controller - name: quay.io/kubernetes-ingress-controller/nginx-ingress-controller
newTag: dev newTag: dev
patchesStrategicMerge:
- service-hostport.yaml

View file

@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-ingress-controller
spec:
replicas: 1
template:
metadata:
annotations:
prometheus.io/port: "10254"
prometheus.io/scrape: "true"
spec:
containers:
- name: nginx-ingress-controller
ports:
- containerPort: 80
hostPort: 80
- containerPort: 443
hostPort: 443
nodeSelector:
ingress-ready: "true"
tolerations:
- key: node-role.kubernetes.io/master
operator: Equal
effect: NoSchedule

View file

@ -78,7 +78,6 @@ minikube addons disable ingress
```console ```console
$ kubectl get pods -n ingress-nginx $ kubectl get pods -n ingress-nginx
NAME READY STATUS RESTARTS AGE NAME READY STATUS RESTARTS AGE
default-http-backend-66b447d9cf-rrlf9 1/1 Running 0 12s
nginx-ingress-controller-fdcdcd6dd-vvpgs 1/1 Running 0 11s nginx-ingress-controller-fdcdcd6dd-vvpgs 1/1 Running 0 11s
``` ```

View file

@ -19,11 +19,6 @@ cd ingress-nginx
### Initial developer environment build ### Initial developer environment build
>**Prequisites**: Minikube must be installed.
See [releases](https://github.com/kubernetes/minikube/releases) for installation instructions.
If you are using **MacOS** and deploying to **minikube**, the following command will build the local nginx controller container image and deploy the ingress controller onto a minikube cluster with RBAC enabled in the namespace `ingress-nginx`:
``` ```
$ make dev-env $ make dev-env
``` ```

View file

@ -100,8 +100,7 @@ All these options (including host) allow environment variables, such as `$HOSTNA
## Examples ## Examples
The following examples show how to deploy and test different distributed tracing systems. These example can be performed The following examples show how to deploy and test different distributed tracing systems. These example can be performed using Minikube.
using Minikube.
### Zipkin ### Zipkin