Compare commits

...

32 Commits

Author SHA1 Message Date
Ganesh Maharaj Mahalingam 0e280f40fa cri-o update fixes
ClearLinux now has cri-o version 1.14.1 which allows multiple plugin
locations and also creates /opt/cni/bin by default. We no longer need
the hacks for them

Fixes: #82
Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-06-04 11:53:36 -07:00
Ganesh Maharaj Mahalingam d31d78c193 calico-node fails to come up cause of all.rp_filter
Currently net.ipv4.conf.all.rp_filter is set to 2 in Clear and
calico-node fails to come up unless that value is either 0 or 1.

Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-05-30 14:17:44 -07:00
Jose Carlos Venegas Munoz 04487a2cfe reset_stack: stop containerd and crio
- If stop CRI service if is running
- Restart the CRI service only if enabled
- Do not enable crio on reset_stack.sh this should be only part of the
setup.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2019-05-29 18:20:33 -07:00
Jose Carlos Venegas Munoz e67630b0bd create_stack: quote variables to avoid code expands
General fixes make my vim mark less warnings from shellcheck

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2019-05-24 11:40:49 -07:00
Jose Carlos Venegas Munoz e08c92f6d5 stack: do not provide CRI socket
kubeadm autodetects the socket path based on defaults from well known
CRI servers.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2019-05-24 11:37:08 -07:00
Jose Carlos Venegas Munoz d00a5ea9d8 README: update flavor setup information.
Add docuementation to use ./clr-k8s-examples/reset_stack.sh help

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2019-05-23 20:38:45 -07:00
Jose Carlos Venegas Munoz a9b3b5c506 create_stack: Add init and cni subcommands
Add more subcommands to to increase granularity

init: start cluster
cni: setup network

This functionality already existed, we only handle
subcommands in a more dynamic way.

Fixes: #92

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2019-05-23 18:56:59 -07:00
Ganesh Maharaj Mahalingam 24f248b02f Set reverse path forwarding to strict.
Calico requires the default reverse path forwarding to be either 0 (no
validation) or 1 (strict validation). The default value of 2 (loose
validation) prevents calico from completing the setup and the pod is
always stuck getting ready.

Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-05-18 14:13:13 -07:00
Ganesh Maharaj Mahalingam d688cbb693 Download OVMF if it doesn't exist
Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-05-01 09:57:04 -07:00
Ganesh Maharaj Mahalingam 4e82cf411d Fix readme to add k8s version dependency
Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-04-04 10:56:23 -07:00
Saikrishna Edupuganti af56d51499 Remove applying runtimeclass CRD
CRD was removed as part of 1.14 update. Missed update to create_stack

Fixes: #84

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-04-04 10:01:36 -07:00
Eric Ernst f863bb7f1f runtimeClass updates for kubernetes 1.14
RuntimeClass moved from alpha to beta. Remove the feature gates, remove
the runtimeClass CRD since it is a built in type, and take the new data
structure into account.

Fixes: #77

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
2019-04-03 11:23:40 -07:00
Eric Ernst d0c7bb3513 kata-deploy: update to match what's on Kata master
We updated to use containerd v2 shim - pull in latest from master

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
2019-03-28 13:09:39 -07:00
Saikrishna Edupuganti 4f38e14245 Turn on static policy for CPU manager
This is finally supported in Kata 1.6
Update memory limit for kata to run in guaranteed test case

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-03-27 10:27:12 -07:00
Saikrishna Edupuganti 3b7e7f75d1 Updated top-level README to point to admit-kata
Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-03-27 10:26:54 -07:00
Saikrishna Edupuganti 39b454045d Copied the README too
Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-03-27 10:26:54 -07:00
Saikrishna Edupuganti fe57aa93ff Upstream artifact for kata admission controller
Get upstream artifacts of kata admission controller from
https://github.com/kata-containers/tests/tree/master/kata-webhook
Commit: 5ad2cec

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-03-27 10:26:54 -07:00
Saikrishna Edupuganti 0417be1cdd Update README.md
Add note about environment variables that can be used to customize the setup
2019-03-26 16:35:25 -07:00
Ganesh Maharaj Mahalingam 02750e991c Make firecracker setup configurable
Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-03-22 17:11:57 -07:00
Saikrishna Edupuganti dc345d4bdf Do not restart containerd, remove stop kubelet
In case of containerd there is no need to restart. Restart for crio is needed
when it manages the networks ns lifecycle. Removed the kubelet stop step which
was a leftover from earlier device plugin install.

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-03-20 13:23:16 -07:00
Manohar Castelino 935bb69cfd Eliminate legacy annotation
We only support kubernetes versions with support for runtimeClass.
Remove the legacy annotations to reduce confusion.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2019-03-14 10:03:37 -07:00
Manohar Castelino e5c55c3c0d Update webhook setup and documentation
The admission controller is now able to access full context.
Hence explicit tagging of pod manifests to exclude them from
kata is no longer required.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2019-03-14 10:03:37 -07:00
Manohar Castelino a6d2f487d8 Disable proxy
Disable proxy setup if the host does not have proxy setup in
the enviornment variables

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2019-03-12 09:57:44 -07:00
Saikrishna Edupuganti ed9f71ee92 Update README.md 2019-03-10 09:23:50 -07:00
Saikrishna Edupuganti c2e932ac7b Hotfix for rsync update in new clear (box?)
Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-02-26 17:31:55 -08:00
Saikrishna Edupuganti 13226c0c72 Update README.md 2019-02-22 19:35:41 -08:00
Saikrishna Edupuganti be17bc3ab7 Use kata-deploy to install and configure kata
Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
2019-02-22 19:34:49 -08:00
Saikrishna Edupuganti b76ff0a4d3 Update multi-network readme
Add steps to show use of helper scripts
2019-02-20 17:05:24 -08:00
Ganesh Maharaj Mahalingam d57b6b187f kata_firecracker.sh script cleanup.
* Remove duplicate lifecycle entry in crio.conf
* Remove fc config.toml as that is provided by the distro.

Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-02-20 14:46:00 -08:00
Ganesh Maharaj Mahalingam b92dd0e5ed Check crio.conf before copying
Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-02-19 13:02:40 -08:00
Manohar Castelino 5cd217a510 Disable devicemapper udev sync
Disable devicemapper udev sync. Without this the storage device
will not be discovered post system reboot

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2019-02-12 19:11:41 -08:00
Manohar Castelino ac79ef38c5 Downloading OVMF causes issues with libvirt
The parent box is already downloading the OVMF firmware.
Just use the firmware that is already downloaded.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
2019-02-12 16:17:18 -08:00
26 changed files with 369 additions and 240 deletions
@@ -2,8 +2,6 @@ apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: rook-ceph-system name: rook-ceph-system
labels:
kata: "false"
--- ---
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition kind: CustomResourceDefinition
-2
View File
@@ -2,8 +2,6 @@ apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: rook-ceph name: rook-ceph
labels:
kata: "false"
--- ---
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
@@ -0,0 +1,46 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kubelet-kata-cleanup
namespace: kube-system
spec:
selector:
matchLabels:
name: kubelet-kata-cleanup
template:
metadata:
labels:
name: kubelet-kata-cleanup
spec:
serviceAccountName: kata-label-node
nodeSelector:
katacontainers.io/kata-runtime: cleanup
containers:
- name: kube-kata-cleanup
image: katadocker/kata-deploy
imagePullPolicy: Always
command: [ "bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh reset" ]
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
privileged: false
volumeMounts:
- name: dbus
mountPath: /var/run/dbus
- name: systemd
mountPath: /run/systemd
volumes:
- name: dbus
hostPath:
path: /var/run/dbus
- name: systemd
hostPath:
path: /run/systemd
updateStrategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
@@ -0,0 +1,69 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kata-deploy
namespace: kube-system
spec:
selector:
matchLabels:
name: kata-deploy
template:
metadata:
labels:
name: kata-deploy
spec:
serviceAccountName: kata-label-node
containers:
- name: kube-kata
image: katadocker/kata-deploy
imagePullPolicy: Always
lifecycle:
preStop:
exec:
command: ["bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh cleanup"]
command: [ "bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh install" ]
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
privileged: false
volumeMounts:
- name: crio-conf
mountPath: /etc/crio/
- name: containerd-conf
mountPath: /etc/containerd/
- name: kata-artifacts
mountPath: /opt/kata/
- name: dbus
mountPath: /var/run/dbus
- name: systemd
mountPath: /run/systemd
- name: local-bin
mountPath: /usr/local/bin/
volumes:
- name: crio-conf
hostPath:
path: /etc/crio/
- name: containerd-conf
hostPath:
path: /etc/containerd/
- name: kata-artifacts
hostPath:
path: /opt/kata/
type: DirectoryOrCreate
- name: dbus
hostPath:
path: /var/run/dbus
- name: systemd
hostPath:
path: /run/systemd
- name: local-bin
hostPath:
path: /usr/local/bin/
updateStrategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
@@ -0,0 +1,29 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kata-label-node
namespace: kube-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: node-labeler
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: kata-label-node-rb
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: node-labeler
subjects:
- kind: ServiceAccount
name: kata-label-node
namespace: kube-system
@@ -1,6 +1,5 @@
kind: RuntimeClass kind: RuntimeClass
apiVersion: node.k8s.io/v1alpha1 apiVersion: node.k8s.io/v1beta1
metadata: metadata:
name: kata-fc name: kata-fc
spec: handler: kata-fc
runtimeHandler: kata-fc
@@ -1,14 +1,12 @@
--- ---
kind: RuntimeClass kind: RuntimeClass
apiVersion: node.k8s.io/v1alpha1 apiVersion: node.k8s.io/v1beta1
metadata: metadata:
name: kata name: kata
spec: handler: kata
runtimeHandler: kata-qemu
--- ---
kind: RuntimeClass kind: RuntimeClass
apiVersion: node.k8s.io/v1alpha1 apiVersion: node.k8s.io/v1beta1
metadata: metadata:
name: kata-qemu name: kata-qemu
spec: handler: kata-qemu
runtimeHandler: kata-qemu
@@ -1,26 +0,0 @@
kind: CustomResourceDefinition
apiVersion: apiextensions.k8s.io/v1beta1
metadata:
name: runtimeclasses.node.k8s.io
labels:
addonmanager.kubernetes.io/mode: Reconcile
spec:
group: node.k8s.io
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
names:
plural: runtimeclasses
singular: runtimeclass
kind: RuntimeClass
scope: Cluster
validation:
openAPIV3Schema:
properties:
spec:
properties:
runtimeHandler:
type: string
pattern: '^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?$'
@@ -15,6 +15,22 @@ file is provided, which enables SR-IOV for the above `rootDevices`
> NOTE: This assumes homogenous nodes in the cluster > NOTE: This assumes homogenous nodes in the cluster
### Pre-req (SR-IOV only)
One each SR-IOV node make sure `VT-d` is enabled in the BIOS and `intel_iommu=on` on kernel commandline.
Setup systemd to bring up VFs on designated interfaces bound to network driver or `vfio-pci`
```bash
# Make sure vfio-pci is loaded on boot
echo 'vfio-pci' | sudo tee /etc/modules-load.d/sriov.conf
sudo systemctl restart systemd-modules-load.service
sudo cp systemd/sriov.sh /usr/bin/sriov.sh
sudo cp systemd/sriov.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now sriov.service
```
### Install ### Install
To install and configure `multus-cni` on all nodes, along with To install and configure `multus-cni` on all nodes, along with
@@ -140,10 +140,8 @@ spec:
- cp /tmp/cni/bin/{multus,sriov,vfioveth,jq} /host/opt/cni/bin/; - cp /tmp/cni/bin/{multus,sriov,vfioveth,jq} /host/opt/cni/bin/;
/tmp/multus/install-multus-conf.sh; /tmp/multus/install-multus-conf.sh;
/tmp/multus/install-certs.sh; /tmp/multus/install-certs.sh;
systemctl stop kubelet; echo "Restarting crio kubelet";
echo "Restarting crio/containerd, kubelet"; systemctl restart crio; # Needed when crio manages ns lifecycle
systemctl restart containerd;
systemctl restart crio;
systemctl restart kubelet; systemctl restart kubelet;
volumeMounts: volumeMounts:
- name: usr-bin - name: usr-bin
+13 -42
View File
@@ -1,5 +1,8 @@
# How to setup the cluster # How to setup the cluster
## Prerequisite
This setup currently will work with k8s 1.14 & above. Any version of k8s before that might work, but is not guaranteed.
## Sample multi-node vagrant setup ## Sample multi-node vagrant setup
To be able to test this tool, you can create a 3-node vagrant setup. In this tutorial, we will talk about using [libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt), but you can use any hypervisor that you are familiar with. To be able to test this tool, you can create a 3-node vagrant setup. In this tutorial, we will talk about using [libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt), but you can use any hypervisor that you are familiar with.
@@ -8,6 +11,7 @@ To be able to test this tool, you can create a 3-node vagrant setup. In this tut
* `vagrant up --provider=libvirt` * `vagrant up --provider=libvirt`
Now you have a 3 node cluster up and running. Each of them have 2 vCPU, 4GB Memory, 2x10GB disks, 1 additional private network. Now you have a 3 node cluster up and running. Each of them have 2 vCPU, 4GB Memory, 2x10GB disks, 1 additional private network.
Customize the setup using environment variables. E.g., `NODES=1 MEMORY=8192 CPUS=8 vagrant up --provider=libvirt`
To login to the master node and change to this directory To login to the master node and change to this directory
@@ -46,14 +50,12 @@ master and also uses kubelet config via [`kubeadm.yaml`](kubeadm.yaml)
to propagate cluster wide kubelet configuration to all workers. Customize it if to propagate cluster wide kubelet configuration to all workers. Customize it if
you need to setup other cluster wide properties. you need to setup other cluster wide properties.
There are two flavors of install - There are different flavors to install, run `./create_stack.sh help` to get
more information.
* `minimal`: initialize cluster, add kata runtimeclass, install canal CNI and metrics server
* `all`: minimal, install rook storage, prometheus, ELK, nginx-ingress, etc.,
```bash ```bash
# default is 'all' # default shows help
./create_stack.sh [minimal|all] ./create_stack.sh <subcommand>
``` ```
## Join Workers to the cluster ## Join Workers to the cluster
@@ -91,43 +93,12 @@ An example is
`kubectl apply -f tests/deploy-svc-ing/test-deploy-kata-fc.yaml` `kubectl apply -f tests/deploy-svc-ing/test-deploy-kata-fc.yaml`
## Making Kata the default runtime ## Making Kata the default runtime using admission controller
Today in `crio.conf` runc is the default runtime when a user does not specify If you want to run a cluster where kata is used
`runtimeClass` in the pod spec. If you want to run a cluster where kata is used by default, except for workloads we know for sure will not work with kata, using
by default, except for workloads we know for sure will not work with kata, use [admission webhook](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks)
the [admission webhook](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks) and sample admission controller, follow `admit-kata` [README.md](admit-kata/README.md)
and sample admission controller we created by running -
`kubectl apply -f admit-kata/`
The [admission webhook](admit-kata/webhook-registration.yaml)
is setup to exclude certian namespaces from being run with Kata using filters on namespace labels.
```yaml
namespaceSelector:
matchExpressions:
- {key: "kata", operator: NotIn, values: ["false"]}
```
The rook operators for example are marked as such
```yaml
apiVersion: v1
kind: Namespace
metadata:
name: rook-ceph-system
labels:
kata: "false"
```
Pods not explicitly excluded by the namespace filter are dynamically tagged to
run with Kata with some [exceptions](https://github.com/mcastelino/kubewebhook/blob/topic/hack-kata/examples/pod-annotate/main.go#L25) -
* `hostNetwork: true`
* `rook-ceph` and `rook-ceph-system` namespaces (buggy)
Other pod properties will be added as exceptions in future.
## Accessing control plane services ## Accessing control plane services
+24 -20
View File
@@ -10,17 +10,16 @@ $cpus = (ENV['CPUS'] || 2).to_i
$memory = (ENV['MEMORY'] || 4096).to_i $memory = (ENV['MEMORY'] || 4096).to_i
$disks = 2 $disks = 2
# Using folder prefix instead of uuid until vagrant-libvirt fixes disk cleanup # Using folder prefix instead of uuid until vagrant-libvirt fixes disk cleanup
disk_prefix = File.basename(File.dirname(__FILE__), "/") $disk_prefix = File.basename(File.dirname(__FILE__), "/")
#DISK_UUID = SecureRandom.urlsafe_base64(9)
$disk_size = "10G" $disk_size = "10G"
$box = "AntonioMeireles/ClearLinux" $box = "AntonioMeireles/ClearLinux"
$loader = File.join(File.dirname(__FILE__), "OVMF.fd") File.exists?("/usr/share/qemu/OVMF.fd") ? $loader = "/usr/share/qemu/OVMF.fd" : $loader = File.join(File.dirname(__FILE__), "OVMF.fd")
$vm_name_prefix = "clr" $vm_name_prefix = "clr"
base_ip = IPAddr.new("192.52.100.10") $base_ip = IPAddr.new("192.52.100.10")
hosts = {} $hosts = {}
proxy_ip_list = "" $proxy_ip_list = ""
#DISK_UUID = Time.now.utc.to_i $driveletters = ('a'..'z').to_a
driveletters = ('a'..'z').to_a $setup_fc = true ? (['true', '1'].include? ENV['SETUP_FC'].to_s) : false
if not File.exists?($loader) if not File.exists?($loader)
system('curl -O https://download.clearlinux.org/image/OVMF.fd') system('curl -O https://download.clearlinux.org/image/OVMF.fd')
@@ -47,38 +46,43 @@ Vagrant.configure("2") do |config|
# Mount the current dir at home folder instead of default # Mount the current dir at home folder instead of default
config.vm.synced_folder './', '/vagrant', disabled: true config.vm.synced_folder './', '/vagrant', disabled: true
config.vm.synced_folder './', '/home/clear/' + File.basename(Dir.getwd), type: 'rsync' config.vm.synced_folder './', '/home/clear/' + File.basename(Dir.getwd), type: 'rsync',
rsync__args: ["--verbose", "--archive", "--delete", "-zz", "--copy-links"]
#Setup proxies for all machines #Setup proxies for all machines
(1..$num_instances).each do |i| (1..$num_instances).each do |i|
base_ip = base_ip.succ $base_ip = $base_ip.succ
hosts["clr-%02d" % i] = base_ip.to_s $hosts["clr-%02d" % i] = $base_ip.to_s
end end
hosts.each do |vm_name, ip| $hosts.each do |vm_name, ip|
proxy_ip_list = ("#{proxy_ip_list},#{vm_name},#{ip}") proxy_ip_list = ("#{proxy_ip_list},#{vm_name},#{ip}")
end end
hosts.each do |vm_name, ip| $hosts.each do |vm_name, ip|
config.vm.define vm_name do |c| config.vm.define vm_name do |c|
c.vm.hostname = vm_name c.vm.hostname = vm_name
c.vm.network :private_network, ip: ip, autostart: true c.vm.network :private_network, ip: ip, autostart: true
c.vm.provider :libvirt do |lv| c.vm.provider :libvirt do |lv|
lv.loader = $loader
lv.cpu_mode = "host-passthrough" lv.cpu_mode = "host-passthrough"
lv.nested = true lv.nested = true
lv.loader = $loader
lv.cpus = $cpus lv.cpus = $cpus
lv.memory = $memory lv.memory = $memory
(1..$disks).each do |d| (1..$disks).each do |d|
lv.storage :file, :device => "hd#{driveletters[d]}", :path => "disk-#{disk_prefix}-#{vm_name}-#{d}.disk", :size => $disk_size, :type => "raw" lv.storage :file, :device => "hd#{$driveletters[d]}", :path => "disk-#{$disk_prefix}-#{vm_name}-#{d}.disk", :size => $disk_size, :type => "raw"
end end
end end
if Vagrant.has_plugin?("vagrant-proxyconf") if ENV['http_proxy'] || ENV['HTTP_PROXY']
c.proxy.http = (ENV['http_proxy']||ENV['HTTP_PROXY']) if Vagrant.has_plugin?("vagrant-proxyconf")
c.proxy.https = (ENV['https_proxy']||ENV['HTTPS_PROXY']) c.proxy.http = (ENV['http_proxy']||ENV['HTTP_PROXY'])
c.proxy.no_proxy = (ENV['no_proxy']+"#{proxy_ip_list}" || ENV['NO_PROXY']+"#{proxy_ip_list}" || "localhost,127.0.0.1,172.16.10.10#{proxy_ip_list}") c.proxy.https = (ENV['https_proxy']||ENV['HTTPS_PROXY'])
c.proxy.no_proxy = (ENV['no_proxy']+"#{proxy_ip_list}" || ENV['NO_PROXY']+"#{proxy_ip_list}" || "localhost,127.0.0.1,172.16.10.10#{proxy_ip_list}")
end
end end
c.vm.provision "shell", privileged: false, path: "setup_system.sh" c.vm.provision "shell", privileged: false, path: "setup_system.sh"
c.vm.provision "shell", privileged: false, path: "setup_kata_firecracker.sh" if $setup_fc
c.vm.provision "shell", privileged: false, path: "setup_kata_firecracker.sh"
end
# Include shells bundle to get bash completion and add kubectl's commands to vagrant's shell # Include shells bundle to get bash completion and add kubectl's commands to vagrant's shell
c.vm.provision "shell", privileged: false, inline: 'sudo -E swupd bundle-add shells; echo "source <(kubectl completion bash)" >> $HOME/.bashrc' c.vm.provision "shell", privileged: false, inline: 'sudo -E swupd bundle-add shells; echo "source <(kubectl completion bash)" >> $HOME/.bashrc'
end end
+39
View File
@@ -0,0 +1,39 @@
# Kata Admission controller webhook
Implement a simple admission controller webhook to annotate pods with the
Kata runtime class.
## How to build the admission controller
First build the admission controller image and the associated
Kubernetes yaml files required to instantiate the admission
controller.
```bash
$ docker build -t katadocker/kata-webhook-example:latest .
$ ./create_certs.sh
```
> **Note:**
> Image needs to be published for the webhook needs to work. Alternately
> on a single machine cluster change the `imagePullPolicy` to use the locally
> built image.
## Making Kata the default runtime using an admission controller
Today in `crio.conf` `runc` is the default runtime when a user does not specify
`runtimeClass` in the pod spec. If you want to run a cluster where Kata is used
by default, except for workloads we know for sure will not work with Kata, use
the [admission webhook](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks)
and sample admission controller we created by running
```bash
$ kubectl apply -f deploy/
```
The webhook mutates pods to use the kata runtime class for all pods except
those with
* `hostNetwork: true`
* namespace: `rook-ceph` and `rook-ceph-system`
+28
View File
@@ -0,0 +1,28 @@
#! /bin/bash
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
WEBHOOK_NS=${1:-"default"}
WEBHOOK_NAME=${2:-"pod-annotate"}
WEBHOOK_SVC="${WEBHOOK_NAME}-webhook"
# Create certs for our webhook
openssl genrsa -out webhookCA.key 2048
openssl req -new -key ./webhookCA.key -subj "/CN=${WEBHOOK_SVC}.${WEBHOOK_NS}.svc" -out ./webhookCA.csr
openssl x509 -req -days 365 -in webhookCA.csr -signkey webhookCA.key -out webhook.crt
# Create certs secrets for k8s
kubectl create secret generic \
${WEBHOOK_SVC}-certs \
--from-file=key.pem=./webhookCA.key \
--from-file=cert.pem=./webhook.crt \
--dry-run -o yaml > ./deploy/webhook-certs.yaml
# Set the CABundle on the webhook registration
CA_BUNDLE=$(cat ./webhook.crt | base64 -w0)
sed "s/CA_BUNDLE/${CA_BUNDLE}/" ./deploy/webhook-registration.yaml.tpl > ./deploy/webhook-registration.yaml
# Clean
rm ./webhookCA* && rm ./webhook.crt
@@ -0,0 +1,24 @@
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
apiVersion: admissionregistration.k8s.io/v1beta1
kind: MutatingWebhookConfiguration
metadata:
name: pod-annotate-webhook
labels:
app: pod-annotate-webhook
kind: mutator
webhooks:
- name: pod-annotate-webhook.kata.xyz
clientConfig:
service:
name: pod-annotate-webhook
namespace: default
path: "/mutate"
caBundle: CA_BUNDLE
rules:
- operations: [ "CREATE" ]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
@@ -1,3 +1,7 @@
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -18,6 +22,7 @@ spec:
args: args:
- -tls-cert-file=/etc/webhook/certs/cert.pem - -tls-cert-file=/etc/webhook/certs/cert.pem
- -tls-key-file=/etc/webhook/certs/key.pem - -tls-key-file=/etc/webhook/certs/key.pem
- -exclude-namespaces=rook-ceph-system,rook-ceph
volumeMounts: volumeMounts:
- name: webhook-certs - name: webhook-certs
mountPath: /etc/webhook/certs mountPath: /etc/webhook/certs
+2
View File
@@ -0,0 +1,2 @@
https://github.com/kata-containers/tests/tree/master/kata-webhook
Commit: 5ad2cec
@@ -1,8 +0,0 @@
apiVersion: v1
data:
cert.pem: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMwakNDQWJvQ0NRQ1IrV2diYXlJeHJ6QU5CZ2txaGtpRzl3MEJBUXNGQURBck1Ta3dKd1lEVlFRRERDQncKYjJRdFlXNXViM1JoZEdVdGQyVmlhRzl2YXk1a1pXWmhkV3gwTG5OMll6QWVGdzB4T0RBM01EZ3hOVFEzTXpGYQpGdzB4T1RBM01EZ3hOVFEzTXpGYU1Dc3hLVEFuQmdOVkJBTU1JSEJ2WkMxaGJtNXZkR0YwWlMxM1pXSm9iMjlyCkxtUmxabUYxYkhRdWMzWmpNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXdoVVUKUEpudnZjZzRJSG54d2tKMkZiQldzc1ZvQjh1anhLcHh2Vm92dEREV0tOVU5jaHozbUF0cUJvaXAwVUlqclptUgowZ3RvcWFJOFJpeHFjUDlvVXlwMVNSTVQrYTdVeTY4b0s3d1F2Mnl5QjZ4MjExU2lja2hHaW8xTUpQN0xCRXpGClJWOUlvbXJjZkp2bi91STRWTWVmcmNZcGp2WHBOOHRUdTdWQWcvUkw4NldjSXg4VEVlbU5KNkErUWdWN0VCS00KWVBRMDAzRno1R2RHWi85c2hRNUZDSEJ1QVh3aVFzTHp6UCtOUkVGaG1zMmdHVk9xV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BlU2t2QjJVbktZTnNZdlA2VnNMaVRITStEUmRzc0NnWUVBamwxb1hqMGsrcElySHlQQXo0N2EKSkJVclFBTE1yUDBxV3ZqekkvSEtsZWVKTmIzdnZ3Qm9rZEYrdEQvZjQrYWNaUlRtMHdtMHRrT2dLZXFXSkI2SwpZaG5MOTZXTm4xdVdWc2E5MTZ2NG5pNGc4amhaNHU0dDZLL0ZuVDRsU09EaU1XRjVaQmFiQWl1azNvTWlTL05kCjFJaE5veEpQeDQxZGFlblF6SCs4MkFVQ2dZRUF2NjRDdWEwNkFSNlYrdklDV1FVVTJtWVREOXFkcWxFRkVGbTIKZW1SbTd6Z0Z2dmlFNnZtWk9aOGhTMGhsYXdCZWlFeWJsQkl6UHlweWZmYU0xMGIyaVZ3WFFSbS94Y3ZER2dVQwpha0g0cFdacVVhVjZaaWlWNHVsckI4d3JLTWphOFZzU2k4b1ZGNVkyYml1cFY2TnYyaFFUcmdDa3VBanVVUm5lCi9YMlZPcFVDZ1lCY2M5R1c5SlhLT242aGNML3lub1NiL3pQYTNrM3lFMlZVNWZiamZpK0JQVWxKRzg5T1JDSU0KSGo1c2lVN2pEeGk2VmM5eGo3dDNNVXh4cXlKYTBWaVd5bGZ6WkVzSVNUQmpub04xbSszM3VqbTV6RSs3NGxQUwpPUm4yNWhrTlIvejY0QWZiZjd6Si9jaEVZSndoQS9zK0NjcVptQ0VWaEc4RjgranRyLzhUQVE9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
kind: Secret
metadata:
creationTimestamp: null
name: pod-annotate-webhook-certs
@@ -1,24 +0,0 @@
apiVersion: admissionregistration.k8s.io/v1beta1
kind: MutatingWebhookConfiguration
metadata:
name: pod-annotate-webhook
labels:
app: pod-annotate-webhook
kind: mutator
webhooks:
- name: pod-annotate-webhook.pod.xyz
clientConfig:
service:
name: pod-annotate-webhook
namespace: default
path: "/mutate"
caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMw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bit2NDZEV3IvQm1GZ0pvcld3TjdYM1V5LzFxcitrVVZxc3lGTHBqelRLZXoKVnYweklJZ1hGTmJXbzQ4cFRNenkxTWRjb0RObDVJRlZrczVnQUkzR05nQlJWdFlOYUN1bUpKNGxKM21tUGtTUAp4OW93ZE9qLzVJTFdzdWVkV1UzT2c2UE96TmdPSjRYVXlLS3ZWSG9BdU11MEtvaVk0QUF6VHFXSjNsR1M5L2VwCm1qQW9BTFdSCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
rules:
- operations: [ "CREATE" ]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
namespaceSelector:
matchExpressions:
- {key: "kata", operator: NotIn, values: ["false"]}
+45 -32
View File
@@ -8,12 +8,23 @@ CUR_DIR=$(pwd)
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
function print_usage_exit() { function print_usage_exit() {
echo $"Usage: $0 [minimal|all]" exit_code=${1:-0}
exit 1 cat <<EOT
Usage: $0 [subcommand]
Subcommands:
$(
for cmd in "${!command_handlers[@]}"; do
printf "\t%s:|\t%s\n" "${cmd}" "${command_help[${cmd}]:-Not-documented}"
done | sort | column -t -s "|"
)
EOT
exit "${exit_code}"
} }
function finish() { function finish() {
cd $CUR_DIR cd "${CUR_DIR}"
} }
trap finish EXIT trap finish EXIT
@@ -22,10 +33,10 @@ function cluster_init() {
#to enable the RuntimeClass featuregate #to enable the RuntimeClass featuregate
sudo -E kubeadm init --config=./kubeadm.yaml sudo -E kubeadm init --config=./kubeadm.yaml
rm -rf $HOME/.kube rm -rf "${HOME}/.kube"
mkdir -p $HOME/.kube mkdir -p "${HOME}/.kube"
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo cp -i /etc/kubernetes/admin.conf "${HOME}/.kube/config"
sudo chown $(id -u):$(id -g) $HOME/.kube/config sudo chown "$(id -u):$(id -g)" "${HOME}/.kube/config"
# If this an interactive terminal then wait for user to join workers # If this an interactive terminal then wait for user to join workers
if [ -t 0 ]; then if [ -t 0 ]; then
@@ -33,18 +44,15 @@ function cluster_init() {
fi fi
#Ensure single node k8s works #Ensure single node k8s works
if [ $(kubectl get nodes | wc -l) -eq 2 ]; then if [ "$(kubectl get nodes | wc -l)" -eq 2 ]; then
kubectl taint nodes --all node-role.kubernetes.io/master- kubectl taint nodes --all node-role.kubernetes.io/master-
fi fi
} }
function runtimeclass_kata() { function kata() {
#Add support for kata runtime # Install kata artifacts using kata-deploy
kubectl apply -f 8-kata/runtimeclass_crd.yaml kubectl apply -f 8-kata/deploy/kata-rbac.yaml
while [[ $(kubectl get crd runtimeclasses.node.k8s.io >/dev/null 2>&1) || $? -ne 0 ]]; do kubectl apply -f 8-kata/deploy/kata-deploy.yaml
echo "Waiting for runtime class CRD"
sleep 2
done
kubectl apply -f 8-kata/ kubectl apply -f 8-kata/
} }
@@ -100,8 +108,8 @@ function miscellaneous() {
function minimal() { function minimal() {
cluster_init cluster_init
runtimeclass_kata
cni cni
kata
metrics metrics
} }
@@ -112,20 +120,25 @@ function all() {
miscellaneous miscellaneous
} }
cd $SCRIPT_DIR declare -A command_handlers
if [[ "$#" -eq 0 ]]; then command_handlers[init]=cluster_init
all command_handlers[cni]=cni
exit command_handlers[minimal]=minimal
fi command_handlers[all]=all
command_handlers[help]=print_usage_exit
case "$1" in declare -A command_help
minimal) command_help[init]="Only inits a cluster using kubeadm"
minimal command_help[cni]="Setup network for running cluster"
;; command_help[minimal]="init + cni + kata + metrics"
all) command_help[all]="minimal + storage + monitoring + miscellaneous"
all command_help[help]="show this message"
;;
*) cd "${SCRIPT_DIR}"
print_usage_exit
;; cmd_handler=${command_handlers[${1:-none}]:-unimplemented}
esac if [ "${cmd_handler}" != "unimplemented" ]; then
"${cmd_handler}"
else
print_usage_exit 1
fi
+4 -11
View File
@@ -1,15 +1,10 @@
apiVersion: kubeadm.k8s.io/v1alpha3 apiVersion: kubeadm.k8s.io/v1beta1
kind: InitConfiguration kind: InitConfiguration
nodeRegistration:
criSocket: /var/run/crio/crio.sock
--- ---
apiVersion: kubelet.config.k8s.io/v1beta1 apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration kind: KubeletConfiguration
featureGates: # Allowing for CPU pinning and isolation in case of guaranteed QoS class
RuntimeClass: true cpuManagerPolicy: static
# Kata does not work with static
# https://github.com/kata-containers/runtime/issues/878
# cpuManagerPolicy: static
systemReserved: systemReserved:
cpu: 500m cpu: 500m
memory: 256M memory: 256M
@@ -17,11 +12,9 @@ kubeReserved:
cpu: 500m cpu: 500m
memory: 256M memory: 256M
--- ---
apiVersion: kubeadm.k8s.io/v1alpha3 apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration kind: ClusterConfiguration
networking: networking:
dnsDomain: cluster.local dnsDomain: cluster.local
podSubnet: 10.244.0.0/16 podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12 serviceSubnet: 10.96.0.0/12
apiServerExtraArgs:
feature-gates: RuntimeClass=true
+13 -6
View File
@@ -3,7 +3,10 @@
set -o nounset set -o nounset
#Cleanup #Cleanup
sudo -E kubeadm reset -f --cri-socket="/var/run/crio/crio.sock" reset_cluster() {
sudo -E kubeadm reset -f
}
reset_cluster
for ctr in $(sudo crictl ps --quiet); do for ctr in $(sudo crictl ps --quiet); do
sudo crictl stop "$ctr" sudo crictl stop "$ctr"
@@ -15,9 +18,10 @@ for pod in $(sudo crictl pods --quiet); do
done done
#Forcefull cleanup all artifacts #Forcefull cleanup all artifacts
#This is needed is things really go wrong #This is needed if things really go wrong
sudo systemctl stop kubelet sudo systemctl stop kubelet
sudo systemctl stop crio systemctl is-active crio && sudo systemctl stop crio
systemctl is-active containerd && sudo systemctl stop containerd
sudo pkill -9 qemu sudo pkill -9 qemu
sudo pkill -9 kata sudo pkill -9 kata
sudo pkill -9 kube sudo pkill -9 kube
@@ -39,8 +43,11 @@ sudo -E bash -c "rm -r /var/run/kata-containers/*"
sudo rm -rf /var/lib/rook sudo rm -rf /var/lib/rook
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable kubelet crio sudo systemctl is-active crio && sudo systemctl stop crio
sudo systemctl restart crio sudo systemctl is-active containerd && sudo systemctl stop containerd
sudo systemctl is-enabled crio && sudo systemctl restart crio
sudo systemctl is-enabled containerd && sudo systemctl restart containerd
sudo systemctl restart kubelet sudo systemctl restart kubelet
sudo -E kubeadm reset -f --cri-socket="/var/run/crio/crio.sock" reset_cluster
+1 -48
View File
@@ -4,33 +4,6 @@ set -o errexit
set -o pipefail set -o pipefail
set -o nounset set -o nounset
sudo mkdir -p /etc/kata-containers
# Setup a configuration to be used by firecracker
cat <<EOT | sudo tee /etc/kata-containers/configuration_firecracker.toml
[hypervisor.firecracker]
path = "/usr/bin/firecracker"
kernel = "/usr//share/kata-containers/vmlinux.container"
image = "/usr//share/kata-containers/kata-containers.img"
kernel_params = ""
default_vcpus = 1
default_memory = 4096
default_maxvcpus = 0
default_bridges = 1
block_device_driver = "virtio-mmio"
disable_block_device_use = false
enable_debug = true
use_vsock = true
[shim.kata]
path = "/usr//libexec/kata-containers/kata-shim"
[agent.kata]
[runtime]
internetworking_model="tcfilter"
EOT
# Firecracker can only work with devicemapper # Firecracker can only work with devicemapper
# Setup a sparse disk to be used for devicemapper # Setup a sparse disk to be used for devicemapper
sudo rm -f /var/lib/crio/devicemapper/disk.img sudo rm -f /var/lib/crio/devicemapper/disk.img
@@ -60,32 +33,12 @@ EOT
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable --now devicemapper sudo systemctl enable --now devicemapper
# For now till we address https://github.com/kubernetes-sigs/cri-o/issues/1991
# use a shell script to expose firecracker through kata
cat <<EOT | sudo tee /usr/bin/kata-fc
#!/bin/bash
/usr/bin/kata-runtime --kata-config /etc/kata-containers/configuration_firecracker.toml "\$@"
EOT
sudo chmod +x /usr/bin/kata-fc
# Add firecracker as a second runtime
# Also setup crio to use devicemapper
sudo mkdir -p /etc/crio/
sudo cp /usr/share/defaults/crio/crio.conf /etc/crio/crio.conf
echo -e "\n[crio.runtime.runtimes.kata-qemu]\nruntime_path = \"/usr/bin/kata-runtime\"" | sudo tee -a /etc/crio/crio.conf
echo -e "\n[crio.runtime.runtimes.kata-fc]\nruntime_path = \"/usr/bin/kata-fc\"" | sudo tee -a /etc/crio/crio.conf
sudo sed -i 's|\(\[crio\.runtime\]\)|\1\nmanage_network_ns_lifecycle = true|' /etc/crio/crio.conf
sudo sed -i 's/storage_driver = \"overlay\"/storage_driver = \"devicemapper\"\ sudo sed -i 's/storage_driver = \"overlay\"/storage_driver = \"devicemapper\"\
storage_option = [\ storage_option = [\
\"dm.basesize=8G\",\ \"dm.basesize=8G\",\
\"dm.directlvm_device=\/dev\/loop8\",\ \"dm.directlvm_device=\/dev\/loop8\",\
\"dm.directlvm_device_force=true\",\ \"dm.directlvm_device_force=true\",\
\"dm.override_udev_sync_check=true",\
\"dm.fs=ext4\"\ \"dm.fs=ext4\"\
]/g' /etc/crio/crio.conf ]/g' /etc/crio/crio.conf
+2 -2
View File
@@ -22,6 +22,8 @@ fi
sudo mkdir -p /etc/sysctl.d/ sudo mkdir -p /etc/sysctl.d/
cat <<EOT | sudo bash -c "cat > /etc/sysctl.d/60-k8s.conf" cat <<EOT | sudo bash -c "cat > /etc/sysctl.d/60-k8s.conf"
net.ipv4.ip_forward=1 net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.rp_filter=1
EOT EOT
sudo systemctl restart systemd-sysctl sudo systemctl restart systemd-sysctl
@@ -50,8 +52,6 @@ sudo systemctl daemon-reload
echo "The following kubelet command may complain... it is not an error" echo "The following kubelet command may complain... it is not an error"
sudo systemctl enable --now kubelet crio || true sudo systemctl enable --now kubelet crio || true
sudo mkdir -p /usr/libexec/cni /opt/cni
[ ! -e /opt/cni/bin/cni ] && sudo ln -s /usr/libexec/cni /opt/cni/bin
#Ensure that the system is ready without requiring a reboot #Ensure that the system is ready without requiring a reboot
sudo swapoff -a sudo swapoff -a
sudo systemctl restart systemd-modules-load.service sudo systemctl restart systemd-modules-load.service
@@ -12,7 +12,7 @@ spec:
resources: resources:
limits: limits:
cpu: 1 cpu: 1
memory: 100Mi memory: 500Mi # For kata to run
--- ---
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
@@ -11,9 +11,6 @@ spec:
run: php-apache-kata-qemu run: php-apache-kata-qemu
template: template:
metadata: metadata:
annotations:
io.kubernetes.cri-o.TrustedSandbox: "false"
io.kubernetes.cri.untrusted-workload: "true"
labels: labels:
run: php-apache-kata-qemu run: php-apache-kata-qemu
spec: spec: