<a id="kubernetes-clouds-and-juju"></a>

# Kubernetes clouds and Juju

In Juju, all Kubernetes clouds behave fundamentally the same.

## Kubernetes in Juju

Juju supports both traditional machine clouds as well as Kubernetes clouds. If you are familiar with Kubernetes, the following is a mapping between Kubernetes and Juju concepts:

| Juju                                                                                                     | Kubernetes                                                                                 |
|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [model](https://documentation.ubuntu.com/juju/2.9/reference/model.md#model)                                               | [namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) |
| [machine](https://documentation.ubuntu.com/juju/2.9/reference/machine.md#machine); Juju does not manage this for Kubernetes | [node](https://kubernetes.io/docs/concepts/architecture/nodes/)                            |
| [unit](https://documentation.ubuntu.com/juju/2.9/reference/unit.md#unit)                                                 | [pod](https://kubernetes.io/docs/concepts/workloads/pods/)                                 |
| process in a unit                                                                                        | container                                                                                  |
| [application](https://documentation.ubuntu.com/juju/2.9/reference/application.md#application)                                   | [service](https://kubernetes.io/docs/concepts/services-networking/service/)                |

## Notes on `juju add-k8s`

On Kubernetes clouds, both the cloud definition and the cloud credentials are added through `juju add-k8s`, which reads from your kubeconfig file.

### Authentication types

#### `certificate`

Attributes:

- ClientCertificateData: the kubernetes certificate data (required)
- Token: the kubernetes service account bearer token (required)
- rbac-id: the unique ID key name of the rbac resources (optional)

#### `clientcertificate`

Attributes:

- ClientCertificateData: the kubernetes certificate data (required)
- ClientKeyData: the kubernetes certificate key (required)
- rbac-id: the unique ID key name of the rbac resources (optional)

#### `oauth2`

Attributes:

- Token: the kubernetes token (required)
- rbac-id: the unique ID key name of the rbac resources (optional)

#### `oauth2withcert`

Attributes:

- ClientCertificateData: the kubernetes certificate data (required)
- ClientKeyData: the kubernetes private key data (required)
- Token: the kubernetes token (required)

#### `userpass`

Attributes:

- username: The username to authenticate with. (required)
- password: The password for the specified username. (required)

## Cloud-specific model configuration keys

### `operator-storage`

The storage class used to provision operator storage.

|               |        |
|---------------|--------|
| type          | string |
| default value | “”     |
| immutable     | true   |
| mandatory     | false  |

### `workload-storage`

The preferred storage class used to provision workload storage.

|               |        |
|---------------|--------|
| type          | string |
| default value | “”     |
| immutable     | false  |
| mandatory     | false  |

## Supported constraints

| [CONSTRAINT](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint)                              |                                               |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------|
| conflicting:                                                                                      | `instance-type` vs. `[cores, cpu-power, mem]` |
| supported?                                                                                        |                                               |
| - [allocate-public-ip](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-allocate-public-ip) | ✕                                             |
| - [arch](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-arch)                             | ✕                                             |
| - [container](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-container)                   | ✕                                             |
| - [cores](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-cores)                           | ✕                                             |
| - [cpu-power](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-cpu-power)                   | ✓                                             |
| - [image-id](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-image-id)                     | ✕                                             |
| - [instance-role](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-instance-role)           | ✕                                             |
| - [instance-type](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-instance-type)           | ✕                                             |
| - [mem](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-mem)                               | ✓                                             |
| - [root-disk](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-root-disk)                   | ✕                                             |
| - [root-disk-source](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-root-disk-source)     | ✕                                             |
| - [spaces](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-spaces)                         | ✕                                             |
| - [tags](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-tags)                             | ✓ <br> Used for affinity.                     |
| - [virt-type](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-virt-type)                   | ✕                                             |
| - [zones](https://documentation.ubuntu.com/juju/2.9/reference/constraint.md#constraint-zones)                           | ✕                                             |
<!--
Sadly, the mem and cpu-power constraints do not properly do what's needed for requests and limits; what we have is very simplistic.
-->

## Placement directives

Placement directives aren’t supported on Kubernetes clouds.
