@@ -2,27 +2,25 @@ Title: Using Kubernetes with Juju
22TODO: Should eventually link to k8s-charm developer documentation
33 Add architectural overview/diagram
44 Consider manually adding a cluster via ` add-cloud ` and ` add-credential `
5- Write tutorial on building a cluster using GCE with gcp -integrator
5+ Write tutorial on building a cluster using GCE with azure -integrator
66
77# Using Kubernetes with Juju
88
99Kubernetes ("k8s") provides a flexible architecture for managing containerised
1010applications at scale. See the
1111[ Kubernetes documentation] [ upstream-kubernetes-docs ] for more information.
1212
13- The objective of this page is how to add an existing Kubernetes cluster to
14- Juju. It is not about showing how to install Kubernetes * with* Juju, although
15- we do give pointers on how to do so.
13+ The objective of this page is to give an overview of how an existing Kubernetes
14+ cluster can be integrated with Juju and what the general workflow is once
15+ that's done. Links will be provided to pages that preset more theory as well as
16+ to practical tutorials. Although this page is not about showing how to install
17+ Kubernetes itself, we do give pointers on how to do so.
1618
1719Essentially, Juju is able to treat the added cluster as it does any other of
1820its known clouds (i.e. create models and deploy charms). There are some
1921differences to working with such a cloud and they are called out in the
2022following section.
2123
22- This document refers to page
23- [ Persistent storage and Kubernetes] [ charms-storage-k8s ] in a few places. You
24- may want to familiarise yourself with it now.
25-
2624## Juju Kubernetes-specific workflow
2725
2826The k8s-specific Juju commands are ` add-k8s ` , ` remove-k8s ` , and
@@ -49,7 +47,7 @@ list of known clouds.
4947The ` scale-application ` command is used to scale a Kubernetes cluster. The
5048` add-unit ` and ` remove-unit ` commands do not apply to a Kubernetes model.
5149
52- A Kubernetes cloud also requires Kubernetes-specific charms .
50+ Charms need to be written specifically for a Juju : Kubernetes context .
5351
5452## Using Kubernetes with Juju
5553
@@ -73,25 +71,16 @@ There are many ways to obtain a Kubernetes cluster. Here is a list of
7371suggestions:
7472
7573 - Use the '[ kubernetes-core] [ charm-kc ] ' bundle, which gives a minimal
76- two-machine cluster available in the Charm Store. Tutorial
77- [ Setting up static Kubernetes storage] [ tutorial-k8s-static-pv ] uses this
78- bundle.
74+ two-machine cluster available in the Charm Store.
7975 - Use the '[ canonical-kubernetes] [ charm-cdk ] ' bundle. This is the Canonical
8076 Distribution of Kubernetes (CDK), which is a more sophisticated version of
8177 'kubernetes-core'.
82- - Use the [ conjure-up] [ upstream-conjure-up ] installer. See the following
83- resources for guidance:
84- - The Ubuntu tutorial:
85- [ Install Kubernetes with conjure-up] [ ubuntu-tutorial_install-kubernetes-with-conjure-up ]
86- - The upstream getting started guide:
87- [ Spell Walkthrough] [ upstream-conjure-up-guide ]
88- - Use [ MicroK8s] [ upstream-microk8s ] . This gives you get a local, fully
89- compliant Kubernetes deployment with dynamic persistent volume support. See
90- tutorial [ Using Juju with MicroK8s] [ tutorial-microk8s ] .
91- - Use a bundle made for the major cloud vendors. There are special
92- "integrator" charms that assist with such deployments.
93- [ Search the Charm Store] [ charm-store-integrator ] for 'integrator'. Tutorial
94- [ Using the aws-integrator charm] [ tutorial-k8s-aws ] demonstrates this.
78+ - Use the [ conjure-up] [ upstream-conjure-up ] installer.
79+ - Use [ MicroK8s] [ upstream-microk8s ] . This gives you a local, fully compliant
80+ Kubernetes deployment with dynamic persistent volume support.
81+ - When Kubernetes is deployed via charms, special integrator charms made for
82+ specific cloud vendors can greatly assist (e.g. storage).
83+ [ Search the Charm Store] [ charm-store-integrator ] for 'integrator'.
9584 - Use a public Kubernetes cloud vendor such as
9685 [ Amazon EKS] [ upstream-eks-kubernetes ] ,
9786 [ Azure AKS] [ upstream-aks-kubernetes ] , and
@@ -103,96 +92,39 @@ suggestions:
10392
10493### Add the cluster to Juju
10594
106- We will need some information about the cluster in order to add it to Juju.
107- This is found within the main Kubernetes configuration file.
108-
109- !!! Note:
110- The ` conjure-up ` installer adds the cluster for you. The rest of this
111- section can be skipped if that's what you used.
112-
113- The configuration file can be copied over from the Kubernetes master node (and
114- saved as ` ~/.kube/config ` ). Here is one way you can do this if Juju was used to
115- install the cluster:
116-
117- ``` bash
118- mkdir ~ /.kube
119- juju scp kubernetes-master/0:config ~ /.kube/config
120- ```
95+ Information about the cluster is needed in order to add it to Juju. This is
96+ found within the main Kubernetes configuration file that can be copied over
97+ from the Kubernetes master node (and saved as ` ~/.kube/config ` ). We can then
98+ take advantage of the ` add-k8s ` command as it will parse the configuration file
99+ if copied to the above path. This allows us to quickly add the cluster.
121100
122- We can now take advantage of the ` add-k8s ` command as it will parse the
123- configuration file if copied to the above path. This allows us to quickly add
124- the cluster, which we have arbitrarily called 'k8s-cloud':
125-
126- ``` bash
127- juju add-k8s k8s-cloud
128- ```
129-
130- Confirm the successful addition of the cloud with the ` clouds ` command.
101+ Note that the ` conjure-up ` installer adds the cluster for you.
131102
132103### Add a model
133104
134- Add a model in the usual way. We've arbitrarily called it 'k8s-model':
135-
136- ``` bash
137- juju add-model k8s-model k8s-cloud
138- ```
139-
140- This will cause a Kubernetes namespace in the cluster to be created that will
141- host all of the pods and other resources for that model. The namespace is the
142- name of the Juju model. A Kubernetes Juju model also starts off with a storage
143- pool called 'kubernetes'. You can see this with the ` storage-pools ` command.
144-
145- !!! Note:
146- We reuse the model name of 'k8s-model' elsewhere on this page to designate,
147- in general, a Kubernetes Juju model.
105+ Add a model in the usual way, with the ` add-model ` command. This will cause a
106+ Kubernetes namespace in the cluster to be created that will host all of the
107+ pods and other resources for that model. The namespace is the name of the Juju
108+ model. A Kubernetes Juju model also starts off with a storage pool called
109+ 'kubernetes'.
148110
149111### Create persistent storage
150112
151113Create persistent static volumes for operator storage if your chosen backing
152114cloud's storage is not supported natively by Kubernetes. You will need to do
153- the same for charm storage if your charm has storage requirements. Here, we
154- show examples for creating static volumes for both types:
155-
156- ``` bash
157- kubectl create -f operator-storage.yaml
158- kubectl create -f charm-storage-vol1.yaml
159- ```
160-
161- For in-depth coverage on this topic see tutorial
162- [ Setting up static Kubernetes storage] [ tutorial-k8s-static-pv ] .
115+ the same for charm storage if your charm has storage requirements. This is done
116+ with the Kubernetes tool ` kubectl ` .
163117
164118### Create storage pools
165119
166- Create storage pools for operator storage and, if needed, charm storage. We
167- show examples for creating pools of both types:
168-
169- ``` bash
170- juju create-storage-pool operator-storage kubernetes \
171- storage-class=juju-operator-storage \
172- storage-provisioner=kubernetes.io/no-provisioner
173- juju create-storage-pool k8s-pool kubernetes \
174- storage-class=juju-unit-storage \
175- storage-provisioner=kubernetes.io/no-provisioner
176- ```
177-
178- The above tutorial also covers storage pool creation!
120+ Create storage pools for operator storage and, if needed, charm storage. This
121+ is done in the usual way, with the ` create-storage-pool ` command.
179122
180123### Deploy a Kubernetes charm
181124
182- A Kubernetes-specific charm is deployed in standard fashion. If the charm has
183- storage requirements you will need to specify them, as you do with a normal
184- charm. For example, here is a charm that uses the previously created charm
185- storage called 'k8s-pool':
186-
187- ``` bash
188- juju deploy cs:~ wallyworld/mariadb-k8s --storage database=k8s-pool,10M
189- ```
190-
191- The [ Using Juju storage] [ charms-storage-juju-deploy ] page covers the above
192- syntax.
193-
194- If you want to deploy a Kubernetes bundle see section
195- [ Kubernetes bundles] [ charms-bundles-k8s ] .
125+ A Kubernetes-specific charm is deployed in standard fashion, with the ` deploy `
126+ command. If the charm has storage requirements you will need to specify them,
127+ as you do with a normal charm.
196128
197129#### Configuration
198130
@@ -232,6 +164,27 @@ Keys 'juju-external-hostname' and 'juju-application-path' control how the
232164application is exposed externally using a Kubernetes Ingress Resource in
233165conjunction with the configured ingress controller (default: nginx).
234166
167+ ## Storage theory and practical guides
168+
169+ Page [ Persistent storage and Kubernetes] [ charms-storage-k8s ] explains how Juju
170+ works with Kubernetes storage.
171+
172+ The following practical guides are available:
173+
174+ - The ` conjure-up ` installer can be used to install Kubernetes. See the
175+ following resources for guidance:
176+ - The Ubuntu tutorial:
177+ [ Install Kubernetes with conjure-up] [ ubuntu-tutorial_install-kubernetes-with-conjure-up ]
178+ - The upstream getting started guide:
179+ [ Spell Walkthrough] [ upstream-conjure-up-guide ]
180+ - Tutorial [ Setting up static Kubernetes storage] [ tutorial-k8s-static-pv ]
181+ shows how to set up statically provisioned persistent volumes with Juju by
182+ way of the 'kubernetes-core' charm.
183+ - Tutorial [ Using Juju with MicroK8s] [ tutorial-microk8s ] provides steps for
184+ getting started with Juju and MicroK8s.
185+ - Tutorial [ Using the aws-integrator charm] [ tutorial-k8s-aws ] demonstrates
186+ deploying Kubernetes with Juju on AWS with an integrator charm.
187+
235188
236189<!-- LINKS -->
237190
@@ -240,8 +193,6 @@ conjunction with the configured ingress controller (default: nginx).
240193[ ubuntu-tutorial_install-kubernetes-with-conjure-up ] : https://tutorials.ubuntu.com/tutorial/install-kubernetes-with-conjure-up#0
241194[ charm-store-integrator ] : https://jujucharms.com/q/integrator
242195[ charms-storage-k8s ] : ./charms-storage-k8s.md
243- [ charms-bundles-k8s ] : ./charms-bundles.md#kubernetes-bundles
244- [ charms-storage-juju-deploy ] : ./charms-storage.md#juju-deploy
245196[ tutorial-microk8s ] : ./tutorial-microk8s.md
246197[ tutorial-k8s-static-pv ] : ./tutorial-k8s-static-pv.md
247198[ tutorial-k8s-aws ] : ./tutorial-k8s-aws.md
0 commit comments