clarify example

This commit is contained in:
iwilltry42 2019-10-17 08:07:03 +02:00
parent f3e2ef5508
commit 36bda94dbd

View File

@ -4,11 +4,14 @@
### 1. via Ingress ### 1. via Ingress
In this example, we will deploy a simple nginx webserver deployment and make it accessible via Iingress.
Therefore, we have to create the cluster in a way, that the internal port 80 (where the `traefik` ingress controller is listening on) is exposed on the host system.
1. Create a cluster, mapping the ingress port 80 to localhost:8081 1. Create a cluster, mapping the ingress port 80 to localhost:8081
`k3d create --api-port 6550 --publish 8081:80 --workers 2` `k3d create --api-port 6550 --publish 8081:80 --workers 2`
- Note: `--api-port 6550` is not required for the example to work. It's used to have `k3s`'s ApiServer listening on port 6550 with that port mapped to the host system. - Note: `--api-port 6550` is not required for the example to work. It's used to have `k3s`'s API-Server listening on port 6550 with that port mapped to the host system.
2. Get the kubeconfig file 2. Get the kubeconfig file
@ -23,6 +26,7 @@
`kubectl create service clusterip nginx --tcp=80:80` `kubectl create service clusterip nginx --tcp=80:80`
5. Create an ingress object for it with `kubectl apply -f` 5. Create an ingress object for it with `kubectl apply -f`
*Note*: `k3s` deploys [`traefik`](https://github.com/containous/traefik) as the default ingress controller
```YAML ```YAML
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
@ -83,10 +87,12 @@
## Connect with a local insecure registry ## Connect with a local insecure registry
This guide takes you through setting up a local insecure (http) registry and integrating it into your workflow so that: This guide takes you through setting up a local insecure (http) registry and integrating it into your workflow so that:
- you can push to the registry from your host - you can push to the registry from your host
- the cluster managed by k3d can pull from that registry - the cluster managed by k3d can pull from that registry
The registry will be named `registry.local` and run on port `5000`. The registry will be named `registry.local` and run on port `5000`.
### Create the registry ### Create the registry
<pre> <pre>
@ -130,7 +136,7 @@ sandbox_image = "{{ .NodeConfig.AgentConfig.PauseImage }}"
Finally start a cluster with k3d, passing-in the config template: Finally start a cluster with k3d, passing-in the config template:
``` ```bash
CLUSTER_NAME=k3s-default CLUSTER_NAME=k3s-default
k3d create \ k3d create \
--name ${CLUSTER_NAME} \ --name ${CLUSTER_NAME} \
@ -148,7 +154,7 @@ k3d create \
Push an image to the registry: Push an image to the registry:
``` ```bash
docker pull nginx:latest docker pull nginx:latest
docker tag nginx:latest registry.local:5000/nginx:latest docker tag nginx:latest registry.local:5000/nginx:latest
docker push registry.local:5000/nginx:latest docker push registry.local:5000/nginx:latest
@ -156,7 +162,7 @@ docker push registry.local:5000/nginx:latest
Deploy a pod referencing this image to your cluster: Deploy a pod referencing this image to your cluster:
``` ```bash
cat <<EOF | kubectl apply -f - cat <<EOF | kubectl apply -f -
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -188,7 +194,7 @@ EOF
The following script leverages a [Docker loopback volume plugin](https://github.com/ashald/docker-volume-loopback) to mask the problematic filesystem away from k3s by providing a small ext4 filesystem underneath `/var/lib/rancher/k3s` (k3s' data dir). The following script leverages a [Docker loopback volume plugin](https://github.com/ashald/docker-volume-loopback) to mask the problematic filesystem away from k3s by providing a small ext4 filesystem underneath `/var/lib/rancher/k3s` (k3s' data dir).
``` ```bash
#!/bin/bash -x #!/bin/bash -x
CLUSTER_NAME="${1:-k3s-default}" CLUSTER_NAME="${1:-k3s-default}"