"
```
]
.right-column[
```yaml
# In Deployment's Pod spec:
volumes:
- name: certificates-volume
secret:
secretName: kuryr-certificates
# In Pod's container spec
volumeMounts:
- name: certificates-volume
mountPath: "/etc/ssl/certs/os-ca.crt"
subPath: kuryr-ca-bundle.crt
readOnly: true
```
]
---
# Kubernetization
## kuryr-controller
**Issue:** Chicken-and-egg problem: how will kuryr-controller pod networking
get wired without kuryr-controller pod running?!
--
**Solution:** Using host networking for that pod.
```yaml
# In Deployment's Pod spec:
spec:
hostNetwork: true
priorityClassName: system-node-critical
```
--
**Disadvantage:** Port conflicts, security issues.
---
# Kubernetization
## kuryr-daemon
**Requirement:** kuryr-daemon should run on every K8s node.
--
**Solution:** K8s DaemonSets.
```yaml
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: kuryr-cni
spec:
template:
metadata:
name: kuryr-cni
spec:
- name: kuryr-cni
image: kuryr/cni
```
---
# Kubernetization
## kuryr-daemon
**Requirement:** Provide configuration in kuryr.conf file.
**Solution:** ConfigMaps
**Requirement:** Secure access to K8s API
**K8s Solution:** ServiceAccounts
---
# Kubernetization
## kuryr-daemon
**Requirement:** Needs write access to host's kernel networking
--
**K8s Solution:** host-networking + privileged container + mount
`/var/run/openvswitch` and `/proc`
.left-column[
```yaml
# In DaemonSet's Pod spec:
hostNetwork: true
volumes:
- name: proc
hostPath:
path: /proc
- name: openvswitch
hostPath:
path: /var/run/openvswitch
```
]
.right-column[
```yaml
# In Pod's container spec:
securityContext:
privileged: true
volumeMounts:
- name: proc
mountPath: /host_proc
- name: openvswitch
mountPath: /var/run/openvswitch
```
]
---
# Kubernetization
## kuryr-daemon
**Requirement:** Pass some info from Pod's spec into the pod.
--
**Solution:** Pass environment variables.
```yaml
# In Pod's container spec:
env:
- name: KUBERNETES_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: KURYR_CNI_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
```
---
# Kubernetization
## kuryr-daemon
**Requirement:** Injecting kuryr-cni executable and CNI configuration
--
**Solution:** Mounting required host directories
```yaml
# In DaemonSet's Pod spec:
volumes:
- name: bin
hostPath:
path: "/opt/cni/bin"
- name: net-conf
hostPath:
path: "/etc/cni/net.d"
# In Pod's container spec:
volumeMounts:
- name: bin
mountPath: "/opt/cni/bin"
- name: net-conf
mountPath: "/etc/cni/net.d"
```
---
# Kubernetization
## Injecting Python executable
###Motivations:
* Easy distribution
* Easy installation
* Easy upgrade
* Other CNI plugins do that
--
###Challenges:
* It's not a binary, it's a Python script
* Dependencies distribution and conflicts
* Python availability and version mismatches
---
# Kubernetization
## Injecting Python executable - approach #1
.left-column[
### Solution
Just use [PyInstaller](https://www.pyinstaller.org/) to compile the Python
app and its dependencies into a binary and inject it.
]
--
.right-column[
.center[]
]
---
# Kubernetization
## Injecting Python executable - approach #1
.left-column[
### Solution
Just use [PyInstaller](https://www.pyinstaller.org/) to compile the Python
app and its dependencies into a binary and inject it.
### Issues
* Complicated build process (need intermediate "builder" container).
* Weird issues with HTTP connection termination.
* PyInstaller changes module paths, so some tricky checks in `os.vif` started to
fail.
]
.right-column[
.center[]
]
---
# Kubernetization
## Injecting Python executable - approach #2
### Solution
**Python virtual environment** - just copy it onto the host.
--
### Issues
* venvs contain the Python binary - potential CPU architecture mismatches.
* `--relocatable` option simply doesn't work.
---
# Kubernetization
## Injecting Python executable - approach #3 (almost the right one)
### Solution
`docker exec` the kuryr-cni executable inside the container and pass the
stdin and stdout.
envs=($(env | grep ^CNI_))
docker exec ${envs[@]/#/--env } -i "${CONTAINERID}" kuryr-cni \
--config-file /etc/kuryr/kuryr.conf
`$CONTAINERID` can be fetched from K8s API.
--
### Issues
* Docker API >= v1.24 is required to pass env vars.
* Some latency from running command through Docker.
* K8s API unreliable when getting CONTAINERID.
---
# Kubernetization
## Injecting Python executable - approach #4 (or #3.5)
### Solution
Use approach #3, but query Docker API for `$CONTAINERID`.
--
### Issues
* Docker API >= v1.24 is required to pass env vars.
* Some latency from running command through Docker.
* Some more latency from querying Docker API for CONTAINERID.
* Need to assume that labels added to containers created by K8s pods are a
stable API.
---
# Conclusions
## Did we learned something?
* It's working and makes distribution, deployment and management of
Kuryr-Kubernetes installation easy for the admin.
--
* You shouldn't expect to get this right at first try - there's too many
variables.
--
* We've ended up backporting injection solutions through #1 to #4.
--
* Some stuff gets easier when you assume it will only work when application is
run on Kubernetes cluster.
--
## New K8s features
--
* **Operators**
--
* Simplified: allow you to write a K8s app that will manage your app.
* Could be useful e.g. with Kuryr in HA mode.
* No guarantee or ETA when we'll start looking at this.
---
# Kuryr-Kubernetes
## How to use, how to contribute
* Documentation: https://docs.openstack.org/kuryr-kubernetes/latest
* IRC channel: [#openstack-kuryr@Freenode](irc://chat.freenode.net/openstack-kuryr)
* Bugs: https://bugs.launchpad.net/kuryr-kubernetes
* How to contribute: https://wiki.openstack.org/wiki/How_To_Contribute
---
template: section_layout

.medium-text[
Slides are available on
http://creativecommons.org/licenses/by/4.0/
]
---
template: thank_you
# Q&A
## Thank you!
**Slides can be found at:**
- https://dulek.github.io/kuryr-kubernetization
- https://github.com/dulek/kuryr-kubernetization
**Michał Dulko**
 [mdulko@redhat.com](mailto:mdulko@redhat.com)
 [dulek (freenode)](irc://chat.freenode.net/dulek,isnick)
**Daniel Mellado**
 [dmellado@redhat.com](mailto:dmellado@redhat.com)
 [dmellado (freenode)](irc://chat.freenode.net/dmellado,isnick)