Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/k8s win nodes hybrid cluster #2956

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a085569
ensure there is pin priority for docker package to avoid upgrade of d…
pablodav Jun 5, 2018
1185836
ensure there is pin priority for docker package to avoid upgrade of d…
pablodav Jun 5, 2018
7a08ede
Merge branch 'feature/k8s_win' of https://github.com/pablodav/kubespr…
pablodav Jun 10, 2018
51e9efa
remove empty when line
pablodav Jun 10, 2018
39165be
ensure there is pin priority for docker package to avoid upgrade of d…
pablodav Jun 5, 2018
62e80bc
remove empty when line
pablodav Jun 10, 2018
5cb8761
force kubeadm upgrade due to failure without --force flag
pablodav Jun 21, 2018
34bc7a2
Merge branch 'feature/k8s_win' of https://github.com/pablodav/kubespr…
pablodav Jun 21, 2018
2a279e3
CheckNodePIDPressure is not supported in v1.10
Miouge1 Jun 28, 2018
3b773e6
ensure there is pin priority for docker package to avoid upgrade of d…
pablodav Jun 5, 2018
4e40d9a
remove empty when line
pablodav Jun 10, 2018
6c069bc
force kubeadm upgrade due to failure without --force flag
pablodav Jun 21, 2018
e62eb1d
Merge branch 'feature/k8s_win' of https://github.com/pablodav/kubespr…
pablodav Jul 3, 2018
89d4424
added nodeSelector to have compatibility with hybrid cluster with win…
pablodav Jul 3, 2018
e6f8259
fixes in syntax and LF for newline in files
pablodav Jul 4, 2018
67e15c4
fix on yamllint check
pablodav Jul 4, 2018
4092f96
Merge pull request #2946 from Miouge1/remove-pid-predicate
Atoms Jul 4, 2018
4d7426e
Fix terraform env Not effective (#2966)
riverzhang Jul 5, 2018
0b939a4
Improve vault etcd initialization check (#2959)
mattymo Jul 5, 2018
5c617c5
Add tags to deploy components by --tags option (#2960)
mattymo Jul 6, 2018
915ea26
ensure there is pin priority for docker package to avoid upgrade of d…
pablodav Jun 5, 2018
0d1bd1e
remove empty when line
pablodav Jun 10, 2018
f32a14b
force kubeadm upgrade due to failure without --force flag
pablodav Jun 21, 2018
d961d40
added nodeSelector to have compatibility with hybrid cluster with win…
pablodav Jul 3, 2018
d1af8bd
fixes in syntax and LF for newline in files
pablodav Jul 4, 2018
3fad479
fix on yamllint check
pablodav Jul 4, 2018
a8a4265
Merge branch 'feature/k8s_win' of https://github.com/pablodav/kubespr…
pablodav Jul 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
roles:
- { role: kubespray-defaults}
- { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
- { role: win_nodes/kubernetes_patch, tags: win_nodes, when: "kubeadm_enabled and kube_patch_win_nodes" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Atoms

for when, only this needs to be changed?

Could be?

   roles:
     - role: kubespray-defaults
     - role: kubernetes-apps/rotate_tokens
       tags: 
         - rotate_tokens
       when: 
         - secret_changed|default(false)
     - role: win_nodes/kubernetes_patch
       tags: 
         - win_nodes
       when: 
         - kubeadm_enabled 
         - and kube_patch_win_nodes

I haven't found examples to understand this syntax better

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in playbook file, but in tasks files, i think for roles still not working such syntax (need to check)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, haven't found other line I have changed to change now, probably could be reviewed in future PRs.


- hosts: kube-master
any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
Expand Down
8 changes: 4 additions & 4 deletions contrib/terraform/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ This project will create:
- Export the variables for your AWS credentials or edit `credentials.tfvars`:

```
export AWS_ACCESS_KEY_ID="www"
export AWS_SECRET_ACCESS_KEY ="xxx"
export AWS_SSH_KEY_NAME="yyy"
export AWS_DEFAULT_REGION="zzz"
export TF_VAR_AWS_ACCESS_KEY_ID="www"
export TF_VAR_AWS_SECRET_ACCESS_KEY ="xxx"
export TF_VAR_AWS_SSH_KEY_NAME="yyy"
export TF_VAR_AWS_DEFAULT_REGION="zzz"
```
- Rename `contrib/terraform/aws/terraform.tfvars.example` to `terraform.tfvars`

Expand Down
52 changes: 52 additions & 0 deletions docs/upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,55 @@ kubernetes-apps/rotate_tokens role, only pods in kube-system are destroyed and
recreated. All other invalidated service account tokens are cleaned up
automatically, but other pods are not deleted out of an abundance of caution
for impact to user deployed pods.

### Component-based upgrades

A deployer may want to upgrade specific components in order to minimize risk
or save time. This strategy is not covered by CI as of this writing, so it is
not guaranteed to work.

These commands are useful only for upgrading fully-deployed, healthy, existing
hosts. This will definitely not work for undeployed or partially deployed
hosts.

Upgrade etcd:

```
ansible-playbook -b -i inventory/sample/hosts.ini cluster.yml --tags=etcd
```

Upgrade vault:

```
ansible-playbook -b -i inventory/sample/hosts.ini cluster.yml --tags=vault
```

Upgrade kubelet:

```
ansible-playbook -b -i inventory/sample/hosts.ini cluster.yml --tags=node --skip-tags=k8s-gen-certs,k8s-gen-tokens
```

Upgrade Kubernetes master components:

```
ansible-playbook -b -i inventory/sample/hosts.ini cluster.yml --tags=master
```

Upgrade network plugins:

```
ansible-playbook -b -i inventory/sample/hosts.ini cluster.yml --tags=network
```

Upgrade all add-ons:

```
ansible-playbook -b -i inventory/sample/hosts.ini cluster.yml --tags=apps
```

Upgrade just helm (assuming `helm_enabled` is true):

```
ansible-playbook -b -i inventory/sample/hosts.ini cluster.yml --tags=helm
```
3 changes: 3 additions & 0 deletions inventory/sample/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ bin_dir: /usr/local/bin
## Refer to roles/kubespray-defaults/defaults/main.yml before modifying no_proxy
#no_proxy: ""

# patch deployments with selectors when running hybrid with win nodes
kube_patch_win_nodes: false

## Uncomment this if you want to force overlay/overlay2 as docker storage driver
## Please note that overlay2 is only supported on newer kernels
#docker_storage_options: -s overlay2
Expand Down
5 changes: 5 additions & 0 deletions roles/dnsmasq/templates/dnsmasq-autoscaler.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ spec:
- --default-params={"linear":{"nodesPerReplica":{{ dnsmasq_nodes_per_replica }},"preventSinglePointFailure":true}}
- --logtostderr=true
- --v={{ kube_log_level }}
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't safe to always add this selector ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past I have sent merge request with the selector added without if and someone else asked to add something like this.

Copy link
Contributor Author

@pablodav pablodav Jul 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I found @woopstar disliked the idea to have the nodeselector: #2556

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did you find this label: beta.kubernetes.io/os is it documented somewhere, is it used by other installer (kops, kubeadm ?)

Copy link
Contributor

@ant31 ant31 Jul 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beta.kubernetes.io/os: linux
{% endif %}
3 changes: 3 additions & 0 deletions roles/dnsmasq/templates/dnsmasq-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ spec:
tolerations:
- effect: NoSchedule
operator: Exists
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
containers:
- name: dnsmasq
image: "{{ dnsmasq_image_repo }}:{{ dnsmasq_image_tag }}"
Expand Down
9 changes: 9 additions & 0 deletions roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@
notify: restart docker
when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic) and (docker_package_info.pkgs|length > 0)

# This is required to ensure any apt upgrade will not break kubernetes
- name: Set docker pin priority to apt_preferences on Debian family
template:
src: "apt_preferences.d/debian_docker.j2"
dest: "/etc/apt/preferences.d/docker"
owner: "root"
mode: 0644
when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse"] or is_atomic)

- name: ensure service is started if docker packages are already present
service:
name: docker
Expand Down
3 changes: 3 additions & 0 deletions roles/docker/templates/apt_preferences.d/debian_docker.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Package: docker-ce
Pin: version {{ docker_version }}.*
Pin-Priority: 1001
2 changes: 1 addition & 1 deletion roles/download/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
when:
- not skip_downloads|default(false)
- item.value.enabled
- item.value.container
- item.value.container|default(false)
- download_run_once
- group_names | intersect(download.groups) | length
7 changes: 6 additions & 1 deletion roles/etcd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
- facts

- include_tasks: "gen_certs_{{ cert_management }}.yml"
when:
tags:
- etcd-secrets

Expand All @@ -19,11 +18,17 @@
register: "etcd_client_cert_serial_result"
changed_when: false
when: inventory_hostname in groups['k8s-cluster']|union(groups['etcd'])|union(groups['calico-rr']|default([]))|unique|sort
tags:
- master
- network

- name: Set etcd_client_cert_serial
set_fact:
etcd_client_cert_serial: "{{ etcd_client_cert_serial_result.stdout }}"
when: inventory_hostname in groups['k8s-cluster']|union(groups['etcd'])|union(groups['calico-rr']|default([]))|unique|sort
tags:
- master
- network

- include_tasks: "install_{{ etcd_deployment_type }}.yml"
when: is_etcd_master
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ spec:
labels:
k8s-app: kubedns-autoscaler
spec:
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
tolerations:
- effect: NoSchedule
operator: Exists
Expand Down
5 changes: 5 additions & 0 deletions roles/kubernetes-apps/ansible/templates/kubedns-deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ spec:
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
tolerations:
- key: "CriticalAddonsOnly"
operator: "Exists"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ spec:
tolerations:
- effect: NoSchedule
operator: Exists
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
containers:
- name: netchecker-agent
image: "{{ agent_img }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ spec:
app: netchecker-agent-hostnet
spec:
hostNetwork: True
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
{% if kube_version | version_compare('v1.6', '>=') %}
dnsPolicy: ClusterFirstWithHostNet
{% endif %}
Expand Down
5 changes: 5 additions & 0 deletions roles/kubernetes-apps/efk/fluentd/templates/fluentd-ds.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ spec:
priorityClassName: system-node-critical
{% if rbac_enabled %}
serviceAccountName: efk
{% endif %}
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
containers:
- name: fluentd-es
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ spec:
{% endif %}
nodeSelector:
node-role.kubernetes.io/ingress: "true"
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
beta.kubernetes.io/os: linux
{% endif %}
terminationGracePeriodSeconds: 60
containers:
- name: ingress-nginx-controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ spec:
timeoutSeconds: 5
ports:
- containerPort: 8080
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
1 change: 1 addition & 0 deletions roles/kubernetes/master/tasks/kubeadm-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
--ignore-preflight-errors=all
--allow-experimental-upgrades
--allow-release-candidate-upgrades
--force
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks it got inserted but I forgot to remove, anyway it is safe to have this line.
In past two tries to upgrade kubeadm, it failed without --force and asked to add --force flag (tried from v1.10.3 to v1.10.4 and from v1.10.4 to v1.10.5

register: kubeadm_upgrade
# Retry is because upload config sometimes fails
retries: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{"name" : "GeneralPredicates"},
{"name" : "CheckNodeMemoryPressure"},
{"name" : "CheckNodeDiskPressure"},
{"name" : "CheckNodePIDPressure"},
{"name" : "CheckNodeCondition"},
{"name" : "PodToleratesNodeTaints"},
{"name" : "CheckVolumeBinding"}
Expand Down
15 changes: 0 additions & 15 deletions roles/kubernetes/node/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
---
- name: install | Set SSL CA directories
set_fact:
ssl_ca_dirs: "[
{% if ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] -%}
'/usr/share/ca-certificates',
{% elif ansible_os_family == 'RedHat' -%}
'/etc/pki/tls',
'/etc/pki/ca-trust',
{% elif ansible_os_family == 'Debian' -%}
'/usr/share/ca-certificates',
{% endif -%}
]"
tags:
- facts

- name: Set kubelet deployment to host if kubeadm is enabled
set_fact:
kubelet_deployment_type: host
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ spec:
hostNetwork: true
{% if kube_version | version_compare('v1.6', '>=') %}
dnsPolicy: ClusterFirst
{% endif %}
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
containers:
- name: kube-proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ metadata:
k8s-app: kube-nginx
spec:
hostNetwork: true
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
containers:
- name: nginx-proxy
image: {{ nginx_image_repo }}:{{ nginx_image_tag }}
Expand Down
16 changes: 16 additions & 0 deletions roles/kubernetes/secrets/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
- import_tasks: check-certs.yml
tags:
- k8s-secrets
- k8s-gen-certs
- facts

- import_tasks: check-tokens.yml
tags:
- k8s-secrets
- k8s-gen-tokens
- facts

- name: Make sure the certificate directory exits
Expand Down Expand Up @@ -70,10 +72,12 @@
- include_tasks: "gen_certs_{{ cert_management }}.yml"
tags:
- k8s-secrets
- k8s-gen-certs

- import_tasks: upd_ca_trust.yml
tags:
- k8s-secrets
- k8s-gen-certs

- name: "Gen_certs | Get certificate serials on kube masters"
shell: "openssl x509 -in {{ kube_cert_dir }}/{{ item }} -noout -serial | cut -d= -f2"
Expand All @@ -85,6 +89,10 @@
- "kube-controller-manager.pem"
- "kube-scheduler.pem"
when: inventory_hostname in groups['kube-master']
tags:
- master
- kubelet
- node

- name: "Gen_certs | set kube master certificate serial facts"
set_fact:
Expand All @@ -93,6 +101,10 @@
controller_manager_cert_serial: "{{ master_certificate_serials.results[2].stdout|default() }}"
scheduler_cert_serial: "{{ master_certificate_serials.results[3].stdout|default() }}"
when: inventory_hostname in groups['kube-master']
tags:
- master
- kubelet
- node

- name: "Gen_certs | Get certificate serials on kube nodes"
shell: "openssl x509 -in {{ kube_cert_dir }}/{{ item }} -noout -serial | cut -d= -f2"
Expand All @@ -108,7 +120,11 @@
kubelet_cert_serial: "{{ node_certificate_serials.results[0].stdout|default() }}"
kube_proxy_cert_serial: "{{ node_certificate_serials.results[1].stdout|default() }}"
when: inventory_hostname in groups['k8s-cluster']
tags:
- kubelet
- node

- import_tasks: gen_tokens.yml
tags:
- k8s-secrets
- k8s-gen-tokens
12 changes: 12 additions & 0 deletions roles/kubespray-defaults/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,18 @@ proxy_env:
https_proxy: "{{ https_proxy| default ('') }}"
no_proxy: "{{ no_proxy| default ('') }}"

ssl_ca_dirs: >-
[
{% if ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] -%}
'/usr/share/ca-certificates',
{% elif ansible_os_family == 'RedHat' -%}
'/etc/pki/tls',
'/etc/pki/ca-trust',
{% elif ansible_os_family == 'Debian' -%}
'/usr/share/ca-certificates',
{% endif -%}
]

# Vars for pointing to kubernetes api endpoints
is_kube_master: "{{ inventory_hostname in groups['kube-master'] }}"
kube_apiserver_count: "{{ groups['kube-master'] | length }}"
Expand Down
5 changes: 5 additions & 0 deletions roles/network_plugin/flannel/templates/cni-flannel.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ spec:
spec:
{% if rbac_enabled %}
serviceAccountName: flannel
{% endif %}
{% if kube_patch_win_nodes %}
# When having win nodes in cluster without this patch, this pod cloud try to be created in windows
nodeSelector:
beta.kubernetes.io/os: linux
{% endif %}
containers:
- name: kube-flannel
Expand Down
Loading