This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kubevirt-cpu-node-labeller deployment to kubevirt ansible (#574)
(cherry picked from commit 207f583)
- Loading branch information
Ryan Hallisey
authored
Jan 18, 2019
1 parent
f8caa57
commit f5aa033
Showing
8 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- import_playbook: initial_configuration.yml | ||
|
||
- name: Deploy kubevirt-cpu-node-labeller role | ||
hosts: localhost | ||
connection: local | ||
gather_facts: False | ||
environment: | ||
http_proxy: "" | ||
roles: | ||
- role: "kubevirt-cpu-node-labeller" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# kubevirt-cpu-node-labeller | ||
Labells nodes with all supported cpu models on host. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
kubevirt_node_labeller_namespace: "kubevirt" | ||
kubevirt_cpu_node_labeller_files_dir: "{{ role_path }}/templates" | ||
cluster_command: "oc" # in case the roles/playbook is not executed from kubevirt.yml | ||
registry_url: "quay.io" | ||
repo_tag: "ksimon" | ||
docker_tag: "0.0.1" | ||
docker_prefix: "{{ registry_url }}/{{ repo_tag }}" | ||
libvirt_image: "kubevirt/libvirt:4.9.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Check that kubevirt-cpu-node-labeller.yaml still exists in /tmp | ||
stat: | ||
path: "/tmp/kubevirt-cpu-node-labeller.yaml" | ||
register: kubevirt_cpu_node_labeller | ||
|
||
- name: Copy kubevirt-cpu-node-labeller yaml to temp directory | ||
template: | ||
src: "{{ kubevirt_cpu_node_labeller_files_dir }}/kubevirt-cpu-node-labeller-0.0.1.yaml" | ||
dest: "/tmp/kubevirt-cpu-node-labeller.yaml" | ||
when: kubevirt_cpu_node_labeller.stat.exists == false | ||
|
||
- name: Delete Kubevirt cpu-node-labeller | ||
shell: "{{ cluster_command }} delete --ignore-not-found -f /tmp/kubevirt-cpu-node-labeller.yaml -n {{ kubevirt_node_labeller_namespace }}" | ||
|
||
- name: Wait until kubevirt-cpu-node-labeller deamonset is deleted | ||
shell: "{{ cluster_command }} -n {{ kubevirt_node_labeller_namespace }} get ds | grep -o -E kubevirt-cpu-node-labeller | wc -l" | ||
register: result | ||
until: result.stdout == "0" | ||
retries: 24 | ||
delay: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- include_tasks: "{{ apb_action }}.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Check that kubevirt-cpu-node-labeller.yaml still exists in /tmp | ||
stat: | ||
path: "/tmp/kubevirt-cpu-node-labeller.yaml" | ||
register: kubevirt_cpu_node_labeller | ||
|
||
- name: Copy kubevirt-cpu-node-labeller.yaml to temp directory | ||
template: | ||
src: "{{ kubevirt_cpu_node_labeller_files_dir }}/kubevirt-cpu-node-labeller-0.0.1.yaml" | ||
dest: "/tmp/kubevirt-cpu-node-labeller.yaml" | ||
when: kubevirt_cpu_node_labeller.stat.exists == false | ||
|
||
- name: Create kubevirt-cpu-node-labeller | ||
shell: "{{ cluster_command }} create -f /tmp/kubevirt-cpu-node-labeller.yaml -n {{ kubevirt_node_labeller_namespace }}" | ||
|
||
- name: Wait until kubevirt-cpu-node-labeller deamonset is created | ||
shell: "{{ cluster_command }} -n {{ kubevirt_node_labeller_namespace }} get ds | grep -o -E kubevirt-cpu-node-labeller | wc -l" | ||
register: result | ||
until: result.stdout == "1" | ||
retries: 24 | ||
delay: 10 |
97 changes: 97 additions & 0 deletions
97
roles/kubevirt-cpu-node-labeller/templates/kubevirt-cpu-node-labeller-0.0.1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kubevirt-cpu-node-labeller | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: kubevirt-cpu-node-labeller | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- nodes | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- security.openshift.io | ||
resources: | ||
- securitycontextconstraints | ||
verbs: | ||
- use | ||
resourceName: | ||
- privileged | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: kubevirt-cpu-node-labeller | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kubevirt-cpu-node-labeller | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kubevirt-cpu-node-labeller | ||
namespace: {{kubevirt_node_labeller_namespace}} | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
labels: | ||
app: kubevirt-cpu-node-labeller | ||
name: kubevirt-cpu-node-labeller | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: kubevirt-cpu-node-labeller | ||
template: | ||
metadata: | ||
labels: | ||
app: kubevirt-cpu-node-labeller | ||
spec: | ||
serviceAccount: kubevirt-cpu-node-labeller | ||
containers: | ||
- env: | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
image: {{ docker_prefix }}/kubevirt-cpu-node-labeller:{{ docker_tag }} | ||
name: kubevirt-cpu-node-labeller | ||
volumeMounts: | ||
- name: nfd-source | ||
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/" | ||
initContainers: | ||
- image: {{ docker_prefix }}/kubevirt-cpu-model-nfd-plugin:{{ docker_tag }} | ||
command: ["/bin/sh","-c"] | ||
args: ["cp /plugin/dest/cpu-model-nfd-plugin /etc/kubernetes/node-feature-discovery/source.d/;"] | ||
imagePullPolicy: Always | ||
name: cpu-model-nfd-plugin | ||
volumeMounts: | ||
- name: nfd-source | ||
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/" | ||
|
||
- image: {{ libvirt_image }} | ||
command: ["/bin/sh","-c"] | ||
args: ["libvirtd -d; chmod o+rw /dev/kvm; virsh domcapabilities --machine q35 --arch x86_64 --virttype kvm > /etc/kubernetes/node-feature-discovery/source.d/virsh_domcapabilities.xml;"] | ||
imagePullPolicy: Always | ||
name: libvirt | ||
securityContext: | ||
privileged: true | ||
resources: | ||
requests: | ||
devices.kubevirt.io/kvm: "1" | ||
limits: | ||
devices.kubevirt.io/kvm: "1" | ||
volumeMounts: | ||
- name: nfd-source | ||
mountPath: "/etc/kubernetes/node-feature-discovery/source.d/" | ||
|
||
volumes: | ||
- name: nfd-source | ||
emptyDir: {} |