Skip to content

Commit

Permalink
Local k8s cluster with Kind (#51)
Browse files Browse the repository at this point in the history
* Adding kind configs

Signed-off-by: gar <[email protected]>

* Adding kind env

Signed-off-by: gar <[email protected]>

* updating kind nodeport

Signed-off-by: gar <[email protected]>

* Adding namespace file

Signed-off-by: gar <[email protected]>

* Separating out the pod afinity rules for controller and default-backend

Signed-off-by: gar <[email protected]>

* Adding namespace file

Signed-off-by: gar <[email protected]>

* updating readme with curl test

Signed-off-by: gar <[email protected]>
  • Loading branch information
sekka1 authored Dec 19, 2019
1 parent 9372a1f commit 7ff874a
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 4 deletions.
121 changes: 121 additions & 0 deletions clusters/local/kind/README.md
Original file line number Diff line number Diff line change
@@ -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
```
30 changes: 30 additions & 0 deletions clusters/local/kind/config.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions kubernetes/helm/http-echo/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: http-echo
labels:
name: http-ech
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions kubernetes/helm/nginx-ingress/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: ingress
labels:
name: ingress
8 changes: 4 additions & 4 deletions kubernetes/helm/nginx-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ nginx-ingress:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
- key: component
operator: In
values:
- nginx-ingress
- controller
topologyKey: "kubernetes.io/hostname"

defaultBackend:
Expand All @@ -59,8 +59,8 @@ nginx-ingress:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
- key: component
operator: In
values:
- nginx-ingress
- default-backend
topologyKey: "kubernetes.io/hostname"

0 comments on commit 7ff874a

Please sign in to comment.