forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add external hcloud cloud controller manager (kubernetes-sigs#8440)
- Loading branch information
Showing
11 changed files
with
241 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
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,14 @@ | ||
## Values for the external Hcloud Cloud Controller | ||
# external_hcloud_cloud: | ||
# hcloud_api_token: "" | ||
# token_secret_name: hcloud | ||
# | ||
# service_account_name: cloud-controller-manager | ||
# | ||
# controller_image_tag: "latest" | ||
# ## A dictionary of extra arguments to add to the openstack cloud controller manager daemonset | ||
# ## Format: | ||
# ## external_hcloud_cloud.controller_extra_args: | ||
# ## arg1: "value1" | ||
# ## arg2: "value2" | ||
# controller_extra_args: {} |
14 changes: 14 additions & 0 deletions
14
roles/kubernetes-apps/external_cloud_controller/hcloud/defaults/main.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,14 @@ | ||
--- | ||
external_hcloud_cloud: | ||
hcloud_api_token: "" | ||
token_secret_name: hcloud | ||
|
||
service_account_name: cloud-controller-manager | ||
|
||
controller_image_tag: "latest" | ||
## A dictionary of extra arguments to add to the openstack cloud controller manager daemonset | ||
## Format: | ||
## external_hcloud_cloud.controller_extra_args: | ||
## arg1: "value1" | ||
## arg2: "value2" | ||
controller_extra_args: {} |
30 changes: 30 additions & 0 deletions
30
roles/kubernetes-apps/external_cloud_controller/hcloud/tasks/main.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,30 @@ | ||
--- | ||
- name: External Hcloud Cloud Controller | Generate Manifests | ||
template: | ||
src: "{{ item.file }}.j2" | ||
dest: "{{ kube_config_dir }}/{{ item.file }}" | ||
group: "{{ kube_cert_group }}" | ||
mode: 0640 | ||
with_items: | ||
- {name: external-hcloud-cloud-secret, file: external-hcloud-cloud-secret.yml} | ||
- {name: external-hcloud-cloud-service-account, file: external-hcloud-cloud-service-account.yml} | ||
- {name: external-hcloud-cloud-role-bindings, file: external-hcloud-cloud-role-bindings.yml} | ||
- {name: external-hcloud-cloud-controller-manager-ds, file: external-hcloud-cloud-controller-manager-ds.yml} | ||
- {name: external-hcloud-cloud-controller-manager-ds-with-networks, file: external-hcloud-cloud-controller-manager-ds-with-networks.yml} | ||
register: external_hcloud_manifests | ||
when: inventory_hostname == groups['kube_control_plane'][0] | ||
tags: external-hcloud | ||
|
||
- name: External Hcloud Cloud Controller | Apply Manifests | ||
kube: | ||
kubectl: "{{ bin_dir }}/kubectl" | ||
filename: "{{ kube_config_dir }}/{{ item.item.file }}" | ||
state: "latest" | ||
with_items: | ||
- "{{ external_hcloud_manifests.results }}" | ||
when: | ||
- inventory_hostname == groups['kube_control_plane'][0] | ||
- not item is skipped | ||
loop_control: | ||
label: "{{ item.item.file }}" | ||
tags: external-hcloud |
69 changes: 69 additions & 0 deletions
69
...roller/hcloud/templates/external-hcloud-cloud-controller-manager-ds-with-networks.yaml.j2
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,69 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DeamonSet | ||
metadata: | ||
name: hcloud-cloud-controller-manager | ||
namespace: kube-system | ||
labels: | ||
k8s-app: hcloud-cloud-controller-manger | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: hcloud-cloud-controller-manager | ||
template: | ||
metadata: | ||
labels: | ||
app: hcloud-cloud-controller-manager | ||
annotations: | ||
scheduler.alpha.kubernetes.io/critical-pod: '' | ||
spec: | ||
serviceAccountName: {{ external_hcloud_cloud.service_account_name }} | ||
dnsPolicy: Default | ||
tolerations: | ||
- key: "node.cloudprovider.kubernetes.io/uninitialized" | ||
value: "true" | ||
effect: "NoSchedule" | ||
- key: "CriticalAddonsOnly" | ||
operator: "Exists" | ||
- key: "node-role.kubernetes.io/master" | ||
effect: NoSchedule | ||
operator: Exists | ||
- key: "node-role.kubernetes.io/control-plane" | ||
effect: NoSchedule | ||
operator: Exists | ||
- key: "node.kubernetes.io/not-ready" | ||
effect: "NoSchedule" | ||
hostNetwork: true | ||
containers: | ||
- image: {{ docker_image_repo }}/hetznercloud/hcloud-cloud-controller-manager:{{ external_hcloud_cloud.controller_image_tag }} | ||
name: hcloud-cloud-controller-manager | ||
command: | ||
- "/bin/hcloud-cloud-controller-manager" | ||
- "--cloud-provider=hcloud" | ||
- "--leader-elect=false" | ||
- "--allow-untagged-cloud" | ||
- "--allocate-node-cidrs=true" | ||
- "--cluster-cidr=10.244.0.0/16" | ||
args: | ||
{% for key, value in external_hcloud_cloud.controller_extra_args.items() %} | ||
- "{{ '--' + key + '=' + value }}" | ||
{% endfor %} | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 50Mi | ||
env: | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
- name: HCLOUD_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: hcloud | ||
key: token | ||
- name: HCLOUD_NETWORK | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ external_hcloud_cloud.token_secret_name }} | ||
key: {{ external_hcloud_cloud.token_secret_key }} |
61 changes: 61 additions & 0 deletions
61
...nal_cloud_controller/hcloud/templates/external-hcloud-cloud-controller-manager-ds.yaml.j2
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,61 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DeamonSet | ||
metadata: | ||
name: hcloud-cloud-controller-manager | ||
namespace: kube-system | ||
labels: | ||
k8s-app: hcloud-cloud-controller-manger | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: hcloud-cloud-controller-manager | ||
updateStrategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: hcloud-cloud-controller-manager | ||
annotations: | ||
scheduler.alpha.kubernetes.io/critical-pod: '' | ||
spec: | ||
serviceAccountName: {{ external_hcloud_cloud.service_account_name }} | ||
dnsPolicy: Default | ||
tolerations: | ||
- key: "node.cloudprovider.kubernetes.io/uninitialized" | ||
value: "true" | ||
effect: "NoSchedule" | ||
- key: "CriticalAddonsOnly" | ||
operator: "Exists" | ||
- key: "node-role.kubernetes.io/master" | ||
effect: NoSchedule | ||
- key: "node-role.kubernetes.io/control-plane" | ||
effect: NoSchedule | ||
- key: "node.kubernetes.io/not-ready" | ||
effect: "NoSchedule" | ||
containers: | ||
- image: {{ docker_image_repo }}/hetznercloud/hcloud-cloud-controller-manager:{{ external_hcloud_cloud.controller_image_tag }} | ||
name: hcloud-cloud-controller-manager | ||
command: | ||
- "/bin/hcloud-cloud-controller-manager" | ||
- "--cloud-provider=hcloud" | ||
- "--leader-elect=false" | ||
- "--allow-untagged-cloud" | ||
args: | ||
{% for key, value in external_hcloud_cloud.controller_extra_args.items() %} | ||
- "{{ '--' + key + '=' + value }}" | ||
{% endfor %} | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 50Mi | ||
env: | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
- name: HCLOUD_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ external_hcloud_cloud.token_secret_name }} | ||
key: {{ external_hcloud_cloud.token_secret_key }} |
13 changes: 13 additions & 0 deletions
13
...pps/external_cloud_controller/hcloud/templates/external-hcloud-cloud-role-bindings.yml.j2
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,13 @@ | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: system:cloud-controller-manager | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ external_hcloud_cloud.service_account_name }} | ||
namespace: kube-system |
8 changes: 8 additions & 0 deletions
8
...netes-apps/external_cloud_controller/hcloud/templates/external-hcloud-cloud-secret.yml.j2
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,8 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: "{{ external_hcloud_cloud.token_secret_name }}" | ||
namespace: kube-system | ||
data: | ||
token: "{{ external_hcloud_cloud.hcloud_api_token | base64 }}" |
6 changes: 6 additions & 0 deletions
6
...s/external_cloud_controller/hcloud/templates/external-hcloud-cloud-service-account.yml.j2
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,6 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ external_hcloud_cloud.service_account_name }} | ||
namespace: kube-system |
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