From 5ce4733cc5a11526aa62a530dd49d8831d240596 Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Mon, 27 Apr 2020 14:14:22 +0200 Subject: [PATCH] docs: use awesome-pages structure and add content --- docs/.pages | 5 ++ docs/CNAME | 1 + docs/examples/.pages | 4 ++ docs/examples/exposing_services.md | 83 ++++++++++++++++++++++++++++++ docs/examples/registries.md | 5 ++ 5 files changed, 98 insertions(+) create mode 100644 docs/.pages create mode 100644 docs/CNAME create mode 100644 docs/examples/.pages create mode 100644 docs/examples/exposing_services.md create mode 100644 docs/examples/registries.md diff --git a/docs/.pages b/docs/.pages new file mode 100644 index 00000000..f7bc630e --- /dev/null +++ b/docs/.pages @@ -0,0 +1,5 @@ +arrange: + - index.md + - commands.md + - defaults.md + - faq.md \ No newline at end of file diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 00000000..f8ce6efa --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +k3d.io \ No newline at end of file diff --git a/docs/examples/.pages b/docs/examples/.pages new file mode 100644 index 00000000..06f50571 --- /dev/null +++ b/docs/examples/.pages @@ -0,0 +1,4 @@ +title: Examples +arrange: + - exposing_services.md + - registries.md \ No newline at end of file diff --git a/docs/examples/exposing_services.md b/docs/examples/exposing_services.md new file mode 100644 index 00000000..85b25242 --- /dev/null +++ b/docs/examples/exposing_services.md @@ -0,0 +1,83 @@ +# Exposing Services + +## 1. via Ingress + +In this example, we will deploy a simple nginx webserver deployment and make it accessible via ingress. +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 + + `k3d create cluster --api-port 6550 -p 8081:80 --workers 2` + + - 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 + + `export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"` + +3. Create a nginx deployment + + `kubectl create deployment nginx --image=nginx` + +4. Create a ClusterIP service for it + + `kubectl create service clusterip nginx --tcp=80:80` + +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 + apiVersion: extensions/v1beta1 + kind: Ingress + metadata: + name: nginx + annotations: + ingress.kubernetes.io/ssl-redirect: "false" + spec: + rules: + - http: + paths: + - path: / + backend: + serviceName: nginx + servicePort: 80 + ``` + +6. Curl it via localhost + + `curl localhost:8081/` + +## 2. via NodePort + +1. Create a cluster, mapping the port 30080 from worker-0 to localhost:8082 + + `k3d create cluster mycluster -p 8082:30080@kworker[0] --workers 2` + + - Note: Kubernetes' default NodePort range is [`30000-32767`](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport) + +... (Steps 2 and 3 like above) ... + +1. Create a NodePort service for it with `kubectl apply -f` + + ```YAML + apiVersion: v1 + kind: Service + metadata: + labels: + app: nginx + name: nginx + spec: + ports: + - name: 80-80 + nodePort: 30080 + port: 80 + protocol: TCP + targetPort: 80 + selector: + app: nginx + type: NodePort + ``` + +2. Curl it via localhost + + `curl localhost:8082/` diff --git a/docs/examples/registries.md b/docs/examples/registries.md new file mode 100644 index 00000000..bcf9aa8d --- /dev/null +++ b/docs/examples/registries.md @@ -0,0 +1,5 @@ +# Registries + +## Registries configuration file + +...