kube-forge v2: embede python with ansible (kubespray) and cobra as cli building tool
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
snapshot_classes:
|
||||
- name: cinder-csi-snapshot
|
||||
is_default: false
|
||||
force_create: true
|
||||
deletionPolicy: Delete
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Kubernetes Snapshots | Copy Cinder CSI Snapshot Class template
|
||||
template:
|
||||
src: "cinder-csi-snapshot-class.yml.j2"
|
||||
dest: "{{ kube_config_dir }}/cinder-csi-snapshot-class.yml"
|
||||
mode: "0644"
|
||||
register: manifests
|
||||
when:
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
|
||||
- name: Kubernetes Snapshots | Add Cinder CSI Snapshot Class
|
||||
kube:
|
||||
kubectl: "{{ bin_dir }}/kubectl"
|
||||
filename: "{{ kube_config_dir }}/cinder-csi-snapshot-class.yml"
|
||||
state: "latest"
|
||||
when:
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
- manifests.changed
|
||||
@@ -0,0 +1,13 @@
|
||||
{% for class in snapshot_classes %}
|
||||
---
|
||||
kind: VolumeSnapshotClass
|
||||
apiVersion: snapshot.storage.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: "{{ class.name }}"
|
||||
annotations:
|
||||
storageclass.kubernetes.io/is-default-class: "{{ class.is_default | default(false) | ternary("true","false") }}"
|
||||
driver: cinder.csi.openstack.org
|
||||
deletionPolicy: "{{ class.deletionPolicy | default("Delete") }}"
|
||||
parameters:
|
||||
force-create: "{{ class.force_create }}"
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
dependencies:
|
||||
- role: kubernetes-apps/snapshots/snapshot-controller
|
||||
when:
|
||||
- cinder_csi_enabled or csi_snapshot_controller_enabled
|
||||
tags:
|
||||
- snapshot-controller
|
||||
|
||||
- role: kubernetes-apps/snapshots/cinder-csi
|
||||
when:
|
||||
- cinder_csi_enabled
|
||||
tags:
|
||||
- snapshot
|
||||
- cinder-csi-driver
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
snapshot_controller_replicas: 1
|
||||
snapshot_controller_namespace: kube-system
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- name: Check if snapshot namespace exists
|
||||
register: snapshot_namespace_exists
|
||||
kube:
|
||||
kubectl: "{{ bin_dir }}/kubectl"
|
||||
name: "{{ snapshot_controller_namespace }}"
|
||||
resource: "namespace"
|
||||
state: "exists"
|
||||
when: inventory_hostname == groups['kube_control_plane'][0]
|
||||
tags: snapshot-controller
|
||||
|
||||
- name: Snapshot Controller | Generate Manifests
|
||||
template:
|
||||
src: "{{ item.file }}.j2"
|
||||
dest: "{{ kube_config_dir }}/{{ item.file }}"
|
||||
mode: "0644"
|
||||
with_items:
|
||||
- {name: snapshot-ns, file: snapshot-ns.yml, apply: not snapshot_namespace_exists}
|
||||
- {name: rbac-snapshot-controller, file: rbac-snapshot-controller.yml}
|
||||
- {name: snapshot-controller, file: snapshot-controller.yml}
|
||||
register: snapshot_controller_manifests
|
||||
when:
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
- item.apply | default(True) | bool
|
||||
tags: snapshot-controller
|
||||
|
||||
- name: Snapshot Controller | Apply Manifests
|
||||
kube:
|
||||
kubectl: "{{ bin_dir }}/kubectl"
|
||||
filename: "{{ kube_config_dir }}/{{ item.item.file }}"
|
||||
state: "latest"
|
||||
with_items:
|
||||
- "{{ snapshot_controller_manifests.results }}"
|
||||
when:
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
- not item is skipped
|
||||
loop_control:
|
||||
label: "{{ item.item.file }}"
|
||||
tags: snapshot-controller
|
||||
@@ -0,0 +1,104 @@
|
||||
# RBAC file for the snapshot controller.
|
||||
#
|
||||
# The snapshot controller implements the control loop for CSI snapshot functionality.
|
||||
# It should be installed as part of the base Kubernetes distribution in an appropriate
|
||||
# namespace for components implementing base system functionality. For installing with
|
||||
# Vanilla Kubernetes, kube-system makes sense for the namespace.
|
||||
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: snapshot-controller
|
||||
namespace: {{ snapshot_controller_namespace }}
|
||||
|
||||
---
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: snapshot-controller-runner
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumes"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumeclaims"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: [""]
|
||||
resources: ["events"]
|
||||
verbs: ["list", "watch", "create", "update", "patch"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshotclasses"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshotcontents"]
|
||||
verbs: ["create", "get", "list", "watch", "update", "delete", "patch"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshotcontents/status"]
|
||||
verbs: ["patch"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshots"]
|
||||
verbs: ["get", "list", "watch", "update", "patch", "delete"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshots/status"]
|
||||
verbs: ["update", "patch"]
|
||||
|
||||
- apiGroups: ["groupsnapshot.storage.k8s.io"]
|
||||
resources: ["volumegroupsnapshotclasses"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: ["groupsnapshot.storage.k8s.io"]
|
||||
resources: ["volumegroupsnapshotcontents"]
|
||||
verbs: ["create", "get", "list", "watch", "update", "delete", "patch"]
|
||||
- apiGroups: ["groupsnapshot.storage.k8s.io"]
|
||||
resources: ["volumegroupsnapshotcontents/status"]
|
||||
verbs: ["patch"]
|
||||
- apiGroups: ["groupsnapshot.storage.k8s.io"]
|
||||
resources: ["volumegroupsnapshots"]
|
||||
verbs: ["get", "list", "watch", "update", "patch"]
|
||||
- apiGroups: ["groupsnapshot.storage.k8s.io"]
|
||||
resources: ["volumegroupsnapshots/status"]
|
||||
verbs: ["update", "patch"]
|
||||
|
||||
# Enable this RBAC rule only when using distributed snapshotting, i.e. when the enable-distributed-snapshotting flag is set to true
|
||||
# - apiGroups: [""]
|
||||
# resources: ["nodes"]
|
||||
# verbs: ["get", "list", "watch"]
|
||||
|
||||
---
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: snapshot-controller-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: snapshot-controller
|
||||
namespace: {{ snapshot_controller_namespace }}
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: snapshot-controller-runner
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
|
||||
---
|
||||
kind: Role
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: snapshot-controller-leaderelection
|
||||
namespace: {{ snapshot_controller_namespace }}
|
||||
rules:
|
||||
- apiGroups: ["coordination.k8s.io"]
|
||||
resources: ["leases"]
|
||||
verbs: ["get", "watch", "list", "delete", "update", "create"]
|
||||
|
||||
---
|
||||
kind: RoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: snapshot-controller-leaderelection
|
||||
namespace: {{ snapshot_controller_namespace }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: snapshot-controller
|
||||
namespace: {{ snapshot_controller_namespace }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: snapshot-controller-leaderelection
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
@@ -0,0 +1,41 @@
|
||||
# This YAML file shows how to deploy the snapshot controller
|
||||
|
||||
# The snapshot controller implements the control loop for CSI snapshot functionality.
|
||||
# It should be installed as part of the base Kubernetes distribution in an appropriate
|
||||
# namespace for components implementing base system functionality. For installing with
|
||||
# Vanilla Kubernetes, kube-system makes sense for the namespace.
|
||||
|
||||
---
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: snapshot-controller
|
||||
namespace: {{ snapshot_controller_namespace }}
|
||||
spec:
|
||||
replicas: {{ snapshot_controller_replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: snapshot-controller
|
||||
# The snapshot controller won't be marked as ready if the v1 CRDs are unavailable.
|
||||
# The flag --retry-crd-interval-max is used to determine how long the controller
|
||||
# will wait for the CRDs to become available before exiting. The default is 30 seconds
|
||||
# so minReadySeconds should be set slightly higher than the flag value.
|
||||
minReadySeconds: 35
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 0
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: snapshot-controller
|
||||
spec:
|
||||
serviceAccountName: snapshot-controller
|
||||
containers:
|
||||
- name: snapshot-controller
|
||||
image: {{ snapshot_controller_image_repo }}:{{ snapshot_controller_image_tag }}
|
||||
imagePullPolicy: {{ k8s_image_pull_policy }}
|
||||
args:
|
||||
- "--v=5"
|
||||
- "--leader-election={{ 'true' if snapshot_controller_replicas > 1 else 'false' }}"
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: {{ snapshot_controller_namespace }}
|
||||
labels:
|
||||
name: {{ snapshot_controller_namespace }}
|
||||
Reference in New Issue
Block a user