Use kata-deploy to install and configure kata

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
This commit is contained in:
Saikrishna Edupuganti
2019-02-05 19:16:33 +00:00
committed by Ganesh Maharaj Mahalingam
parent b76ff0a4d3
commit be17bc3ab7
5 changed files with 145 additions and 23 deletions
@@ -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: ["/bin/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,64 @@
---
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: ["/bin/bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh cleanup"]
command: ["/bin/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
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
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
+6 -2
View File
@@ -38,7 +38,11 @@ function cluster_init() {
fi
}
function runtimeclass_kata() {
function kata() {
# Install kata artifacts using kata-deploy
kubectl apply -f 8-kata/deploy/kata-rbac.yaml
kubectl apply -f 8-kata/deploy/kata-deploy.yaml
#Add support for kata runtime
kubectl apply -f 8-kata/runtimeclass_crd.yaml
while [[ $(kubectl get crd runtimeclasses.node.k8s.io >/dev/null 2>&1) || $? -ne 0 ]]; do
@@ -100,8 +104,8 @@ function miscellaneous() {
function minimal() {
cluster_init
runtimeclass_kata
cni
kata
metrics
}
@@ -33,27 +33,6 @@ EOT
sudo systemctl daemon-reload
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 /usr/share/defaults/kata-containers/configuration-fc.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/
if [ ! -f /etc/crio/crio.conf ]; then
sudo cp /usr/share/defaults/crio/crio.conf /etc/crio/crio.conf
fi
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/storage_driver = \"overlay\"/storage_driver = \"devicemapper\"\
storage_option = [\
\"dm.basesize=8G\",\