|
| 1 | +.. Licensed to the Apache Software Foundation (ASF) under one |
| 2 | + or more contributor license agreements. See the NOTICE file |
| 3 | + distributed with this work for additional information# |
| 4 | + regarding copyright ownership. The ASF licenses this file |
| 5 | + to you under the Apache License, Version 2.0 (the |
| 6 | + "License"); you may not use this file except in compliance |
| 7 | + with the License. You may obtain a copy of the License at |
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + Unless required by applicable law or agreed to in writing, |
| 10 | + software distributed under the License is distributed on an |
| 11 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 12 | + KIND, either express or implied. See the License for the |
| 13 | + specific language governing permissions and limitations |
| 14 | + under the License. |
| 15 | +
|
| 16 | +The CloudStack Kubernetes Provider |
| 17 | +================================== |
| 18 | + |
| 19 | +Introduction |
| 20 | +------------ |
| 21 | + |
| 22 | +The CloudStack Kubernetes Provider facilitates Kubernetes deployments on Cloudstack. |
| 23 | +It allows Kubernetes to dynamically allocate IP addresses and the respective networking |
| 24 | +rules on CloudStack to ensure seamless TCP, UDP and TCP-Proxy LoadBalancer deployments |
| 25 | +on Kubernetes. |
| 26 | + |
| 27 | +It also automatically manages these rules modifying them based on the deployment as well |
| 28 | +as the size of the cluster. |
| 29 | + |
| 30 | +It was initially the Cloudstack provider in Kubernetes which was later extracted to allow |
| 31 | +for pluggable providers. |
| 32 | + |
| 33 | +The Prebuilt containers are available on `Docker Hub <https://hub.docker.com/r/apache/cloudstack-kubernetes-provider>`_. |
| 34 | + |
| 35 | +Deployment |
| 36 | +---------- |
| 37 | +The CloudStack Kubernetes Provider is automatically deployed when a Kuberentes Cluster is |
| 38 | +created on CloudStack 4.16+ |
| 39 | + |
| 40 | +In order to communicate with CloudStack, a separate service user **kubeadmin** is created |
| 41 | +in the same account as the cluster owner. The provider uses this user's API keys to get |
| 42 | +the details of the cluster as well as update the networking rules. It is imperative that |
| 43 | +this user is not altered or have its keys regenerated. |
| 44 | + |
| 45 | +The provider can also be manually deployed with instructions `here |
| 46 | +<https://github.com/apache/cloudstack-kubernetes-provider/blob/main/README.md>`_ |
| 47 | + |
| 48 | +Further details as well as instructions on how to build and contribute to the project can be found `here |
| 49 | +<https://github.com/apache/cloudstack-kubernetes-provider/blob/main/README.md>`_ |
| 50 | + |
| 51 | +Usage |
| 52 | +----- |
| 53 | + |
| 54 | +In the following example, a LoadBalancer Service is created to balance traffic between the nodes in |
| 55 | +a cluster. The DaemonSet creates pods and maps the ports on the pods to the same ports on the host. |
| 56 | +The LoadBalancer creates an externally-accessible IP address that sends traffic to the correct port |
| 57 | +on the cluster nodes. |
| 58 | + |
| 59 | +#. The following yaml creates a DaemonSet which brings up a pod on every node and maps port 80 and |
| 60 | + 443 from the pod to the node. The LoadBalancer Service then creates a public IP to balance traffic |
| 61 | + on port 80 and 443 between the nodes. |
| 62 | + |
| 63 | + .. parsed-literal:: |
| 64 | + --- |
| 65 | + apiVersion: v1 |
| 66 | + kind: Service |
| 67 | + metadata: |
| 68 | + name: traefik |
| 69 | + annotations: |
| 70 | + service.beta.kubernetes.io/cloudstack-load-balancer-proxy-protocol: enabled |
| 71 | + spec: |
| 72 | + type: LoadBalancer |
| 73 | + ports: |
| 74 | + - name: http |
| 75 | + port: 80 |
| 76 | + targetPort: http |
| 77 | + - name: https |
| 78 | + port: 443 |
| 79 | + targetPort: https |
| 80 | + --- |
| 81 | + apiVersion: v1 |
| 82 | + kind: ConfigMap |
| 83 | + metadata: |
| 84 | + name: traefik-conf |
| 85 | + data: |
| 86 | + traefik.toml: | |
| 87 | + defaultEntryPoints = ["http"] |
| 88 | + [entryPoints] |
| 89 | + [entryPoints.http] |
| 90 | + address = ":80" |
| 91 | + [entryPoints.http.proxyProtocol] |
| 92 | + trustedIPs = ["127.0.0.1/32", "10.0.0.1/32"] |
| 93 | + [entryPoints.https] |
| 94 | + address = ":443" |
| 95 | + [entryPoints.https.proxyProtocol] |
| 96 | + trustedIPs = ["127.0.0.1/32", "10.0.0.1/32"] |
| 97 | + --- |
| 98 | + apiVersion: apps/v1 |
| 99 | + kind: DaemonSet |
| 100 | + metadata: |
| 101 | + name: traefik-ingress-controller |
| 102 | + spec: |
| 103 | + selector: |
| 104 | + matchLabels: |
| 105 | + name: traefik-ingress-controller |
| 106 | + template: |
| 107 | + metadata: |
| 108 | + labels: |
| 109 | + name: traefik-ingress-controller |
| 110 | + spec: |
| 111 | + hostNetwork: true |
| 112 | + containers: |
| 113 | + - args: |
| 114 | + - --configfile=/config/traefik.toml |
| 115 | + image: traefik:1.7.12 |
| 116 | + imagePullPolicy: Always |
| 117 | + name: traefik-ingress |
| 118 | + ports: |
| 119 | + - containerPort: 80 |
| 120 | + hostPort: 80 |
| 121 | + name: http |
| 122 | + protocol: TCP |
| 123 | + - containerPort: 443 |
| 124 | + hostPort: 443 |
| 125 | + name: https |
| 126 | + protocol: TCP |
| 127 | + volumeMounts: |
| 128 | + - mountPath: /config |
| 129 | + name: config |
| 130 | + volumes: |
| 131 | + - configMap: |
| 132 | + defaultMode: 420 |
| 133 | + name: traefik-conf |
| 134 | + name: config |
| 135 | +
|
| 136 | + It can be deployed by running the command |
| 137 | + |
| 138 | + .. parsed-literal:: |
| 139 | + kubectl apply -f https://raw.githubusercontent.com/apache/cloudstack-kubernetes-provider/main/traefik-ingress-controller.yml |
| 140 | +
|
| 141 | +#. On successfully deploying the yaml file, a new Public IP Address in the same network |
| 142 | + as the cluster will be created. It will automatically have the firewall and port forwarding |
| 143 | + rules configured to distribute any traffic amongst the cluster worker nodes |
| 144 | + |
| 145 | +|ckp-ip.png| |
| 146 | + |
| 147 | +|ckp-ip-fw.png| |
| 148 | + |
| 149 | +|ckp-ip-lb.png| |
| 150 | + |
| 151 | +.. |ckp-ip.png| image:: /_static/images/ckp-ip.png |
| 152 | +.. |ckp-ip-fw.png| image:: /_static/images/ckp-ip-fw.png |
| 153 | +.. |ckp-ip-lb.png| image:: /_static/images/ckp-ip-lb.png |
0 commit comments