diff --git a/clusters/local/kind/README.md b/clusters/local/kind/README.md new file mode 100644 index 000000000..53d6d2ef2 --- /dev/null +++ b/clusters/local/kind/README.md @@ -0,0 +1,121 @@ +Kind +======= +Kind is an open source project that brings up a local Kuberenetes environment all +running in Docker. + +Doc: https://kind.sigs.k8s.io/docs/user/quick-start/ + + +# Installation instructions: + +Doc: https://github.com/kubernetes-sigs/kind#installation-and-usage + + +# Usage: + +## Creation: +``` +kind create cluster --config config.yaml --image kindest/node:v1.13.12 +``` + +## List +``` +kind get clusters +``` + +## Delete +``` +kind delete cluster +``` + +## Debug +By defaul if the create command fails it will clean up the Docker containers. + +You can append the `--retain` flag in the `kind create cluster...` command so +it won't remove the Docker containers on failure and you can debug the containers +from there. + +There is also a verbose flag to give you more information on what it is doing: `--v 7` + +# Example deployment + +## nginx-ingress + +``` +cd kubernetes/helm/nginx-ingress/ +``` + +Deploy: +``` +make ENVIRONMENT=kind external-apply +``` + +## http-echo app + +``` +cd kubernetes/helm/http-echo +``` + +Deploy: +``` +kubectl apply -f namespace.yaml +kubectl -n http-echo apply -f . +``` + +Test out the ingress: +```bash +root@ip-10-4-2-98:/home/ubuntu/kubernetes-ops/kubernetes/helm/http-echo# curl -v http://localhost -H "HOST: gar1.example.com" +* Rebuilt URL to: http://localhost/ +* Trying 127.0.0.1... +* TCP_NODELAY set +* Connected to localhost (127.0.0.1) port 80 (#0) +> GET / HTTP/1.1 +> HOST: gar1.example.com +> User-Agent: curl/7.58.0 +> Accept: */* +> +< HTTP/1.1 200 OK +< Server: nginx/1.15.10 +< Date: Thu, 19 Dec 2019 20:28:46 GMT +< Content-Type: text/plain +< Transfer-Encoding: chunked +< Connection: keep-alive +< Vary: Accept-Encoding +< + + +Hostname: echoserver-6bdccfbcd4-jv557 + +Pod Information: + -no pod information available- + +Server values: + server_version=nginx: 1.13.3 - lua: 10008 + +Request Information: + client_address=10.244.1.17 + method=GET + real path=/ + query= + request_version=1.1 + request_scheme=http + request_uri=http://gar1.example.com:8080/ + +Request Headers: + accept=*/* + host=gar1.example.com + user-agent=curl/7.58.0 + x-forwarded-for=10.244.1.1 + x-forwarded-host=gar1.example.com + x-forwarded-port=80 + x-forwarded-proto=http + x-original-uri=/ + x-real-ip=10.244.1.1 + x-request-id=2052b9f9e6a91587c5810773352fe7ab + x-scheme=http + +Request Body: + -no body in request- + +* Connection #0 to host localhost left intact +``` \ No newline at end of file diff --git a/clusters/local/kind/config.yaml b/clusters/local/kind/config.yaml new file mode 100644 index 000000000..ec68fd6c7 --- /dev/null +++ b/clusters/local/kind/config.yaml @@ -0,0 +1,30 @@ +--- +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 + +nodes: +- role: control-plane +- role: worker + extraPortMappings: + - containerPort: 30080 + hostPort: 80 + listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0" + protocol: tcp + - containerPort: 30443 + hostPort: 443 + listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0" + protocol: tcp + kubeadmConfigPatches: + - | + apiVersion: kubeadm.k8s.io/v1beta2 + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + authorization-mode: "AlwaysAllow" +# - role: worker +# extraPortMappings: +# - containerPort: 8080 +# hostPort: 8080 +# listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0" +# protocol: udp # Optional, defaults to tcp \ No newline at end of file diff --git a/kubernetes/helm/http-echo/namespace.yaml b/kubernetes/helm/http-echo/namespace.yaml new file mode 100644 index 000000000..db78534ac --- /dev/null +++ b/kubernetes/helm/http-echo/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: http-echo + labels: + name: http-ech diff --git a/kubernetes/helm/nginx-ingress/environments/kind/values-external.yaml b/kubernetes/helm/nginx-ingress/environments/kind/values-external.yaml new file mode 100644 index 000000000..50bee142c --- /dev/null +++ b/kubernetes/helm/nginx-ingress/environments/kind/values-external.yaml @@ -0,0 +1,20 @@ +nginx-ingress: + controller: + electionID: ingress-controller-leader-external + ingressClass: nginx-external + + # service: + # annotations: + # service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-east-1:11111111111:certificate/1111111-1111-1111-1111-111111111" + + # Whitelisting IPs inbound + # loadBalancerSourceRanges: + # # Temporary ManagedKube + # - 38.30.8.138/32 + # - 1.1.1.1/32 + + service: + type: NodePort + nodePorts: + http: "30080" + https: "30443" diff --git a/kubernetes/helm/nginx-ingress/environments/kind/values-internal.yaml b/kubernetes/helm/nginx-ingress/environments/kind/values-internal.yaml new file mode 100644 index 000000000..08712a405 --- /dev/null +++ b/kubernetes/helm/nginx-ingress/environments/kind/values-internal.yaml @@ -0,0 +1,14 @@ +nginx-ingress: + controller: + electionID: ingress-controller-leader-internal + ingressClass: nginx-internal + + service: + annotations: + service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0 + service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-east-1:11111111111:certificate/1111111-1111-1111-1111-111111111" + + type: NodePort + nodePorts: + http: "31080" + https: "31443" diff --git a/kubernetes/helm/nginx-ingress/namespace.yaml b/kubernetes/helm/nginx-ingress/namespace.yaml new file mode 100644 index 000000000..56903e1f7 --- /dev/null +++ b/kubernetes/helm/nginx-ingress/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: ingress + labels: + name: ingress diff --git a/kubernetes/helm/nginx-ingress/values.yaml b/kubernetes/helm/nginx-ingress/values.yaml index 46da88e8b..50cfc4aa7 100644 --- a/kubernetes/helm/nginx-ingress/values.yaml +++ b/kubernetes/helm/nginx-ingress/values.yaml @@ -42,10 +42,10 @@ nginx-ingress: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - - key: app + - key: component operator: In values: - - nginx-ingress + - controller topologyKey: "kubernetes.io/hostname" defaultBackend: @@ -59,8 +59,8 @@ nginx-ingress: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - - key: app + - key: component operator: In values: - - nginx-ingress + - default-backend topologyKey: "kubernetes.io/hostname"