Test dependencies
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2023-02-22 21:24:42 +01:00
commit f2b0a5e7c7
429 changed files with 20330 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# Copyright 2018 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
kubernetes_bins:
- kubeadm
- kubectl
- kubelet

View File

@ -0,0 +1,58 @@
# Copyright 2020 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Create kubelet directory structure
win_file:
path: "{{ item }}"
state: directory
loop:
- '{{ systemdrive.stdout | trim }}\var\log\kubelet'
- '{{ systemdrive.stdout | trim }}\etc\kubernetes'
- '{{ systemdrive.stdout | trim }}\etc\kubernetes\manifests'
- '{{ systemdrive.stdout | trim }}\etc\kubernetes\pki'
# this is required in 1.22 and below due to invalid absolute path handling
# https://github.com/kubernetes-sigs/image-builder/issues/853
- name: Symlink kubelet pki folder
win_shell: New-Item -path $env:SystemDrive\var\lib\kubelet\etc\kubernetes\pki -type SymbolicLink -value $env:SystemDrive\etc\kubernetes\pki\ -Force
when: kubernetes_semver is version('v1.23.0', '<')
- import_tasks: nssm.yml
when: windows_service_manager == "nssm"
- import_tasks: sc.yml
when: windows_service_manager == "windows_service"
# Dependency selection: https://www.reddit.com/r/ansible/comments/imfdgn/setting_a_variable_conditionally/g41anaf/?utm_source=reddit&utm_medium=web2x&context=3
- name: Ensure kubelet is installed
win_service:
name: kubelet
dependencies: [ "{{ runtime_service }}" ]
start_mode: auto
vars:
dependencies:
containerd: containerd
docker-ee: docker
default: docker
runtime_service: "{{ dependencies[runtime] | default(dependencies['docker']) }}"
- name: Add firewall rule for kubelet
win_firewall_rule:
name: kubelet
localport: 10250
action: allow
direction: in
protocol: tcp
state: present
enabled: yes

View File

@ -0,0 +1,31 @@
# Copyright 2020 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Create kubernetes directory structure
win_file:
path: '{{ kubernetes_install_path }}'
state: directory
- import_tasks: url.yml
- name: Add kubernetes folder to path
win_path:
elements:
- '{{ kubernetes_install_path }}'
scope: Machine
- import_tasks: kubelet.yml
- import_tasks: wins.yml
when: use_wins

View File

@ -0,0 +1,39 @@
# Copyright 2020 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Download nssm
win_get_url:
url: '{{ nssm_url }}'
dest: '{{ kubernetes_install_path }}\'
retries: 5
delay: 3
register: nssm_download
until: nssm_download is not failed
- name: Create kubelet start file for nssm
win_template:
src: templates/StartKubelet.ps1
dest: '{{ kubernetes_install_path }}\StartKubelet.ps1'
- name: Install kubelet via nssm
win_nssm:
name: kubelet
start_mode: auto
state: present
application: '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe'
arguments: '-ExecutionPolicy Bypass -NoProfile {{ kubernetes_install_path }}\StartKubelet.ps1'
app_rotate_bytes: 10485760
stderr_file: '{{ systemdrive.stdout | trim }}\var\log\kubelet\kubelet.err.log'
stdout_file: '{{ systemdrive.stdout | trim }}\var\log\kubelet\kubelet.log'
app_rotate_online: 1

View File

@ -0,0 +1,27 @@
# Copyright 2020 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
# Install kubelet as a windows service
# Requires --windows-service flag: https://github.com/kubernetes/kubernetes/blob/7f23a743e8c23ac6489340bbb34fa6f1d392db9d/cmd/kubelet/app/options/osflags_windows.go#L26
# Does not support kubeadm KUBELET_KUBEADM_ARGS which is used by Cluster API to pass extra user args
- name: Set dockershim args
set_fact:
additional_kubelet_args: "--image-pull-progress-deadline=20m --network-plugin=cni"
when: runtime == "docker-ee" and kubernetes_semver is version('v1.24.0', '<')
- name: Install kubelet as service
win_service:
name: kubelet
start_mode: manual
path: '{{ kubernetes_install_path }}\kubelet.exe --windows-service --cert-dir={{ systemdrive.stdout | trim }}/var/lib/kubelet/pki --config={{ systemdrive.stdout | trim }}/var/lib/kubelet/config.yaml --bootstrap-kubeconfig={{ systemdrive.stdout | trim }}/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig={{ systemdrive.stdout | trim }}/etc/kubernetes/kubelet.conf --hostname-override=$(hostname) --pod-infra-container-image=`"{{ pause_image }}`" --enable-debugging-handlers --cgroups-per-qos=false --enforce-node-allocatable=`"`" --resolv-conf=`"`" --log-dir={{ systemdrive.stdout | trim }}/var/log/kubelet --logtostderr=false {{ additional_kubelet_args if additional_kubelet_args is defined }}'

View File

@ -0,0 +1,24 @@
# Copyright 2020 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Download kubernetes binaries
win_get_url:
url: "{{ kubernetes_base_url }}/{{ item }}.exe"
dest: '{{ kubernetes_install_path }}\'
loop: "{{ kubernetes_bins }}"
retries: 5
delay: 3
register: kubernetes_download
until: kubernetes_download is not failed

View File

@ -0,0 +1,29 @@
# Copyright 2020 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Get wins
win_get_url:
url: '{{ wins_url }}'
dest: '{{ kubernetes_install_path }}'
retries: 5
delay: 3
register: wins_download
until: wins_download is not failed
- name: Register wins.exe
win_command: wins.exe srv app run --register
- name: Ensure that wins service is running
win_service:
name: rancher-wins

View File

@ -0,0 +1,43 @@
# Copyright 2020 The Kubernetes Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# From https://github.com/kubernetes-sigs/sig-windows-tools/blob/master/kubeadm/scripts/PrepareNode.ps1
$FileContent = Get-Content -Path "/var/lib/kubelet/kubeadm-flags.env"
$kubeAdmArgs = $FileContent.TrimStart('KUBELET_KUBEADM_ARGS=').Trim('"')
$args = "--cert-dir=$env:SYSTEMDRIVE/var/lib/kubelet/pki",
"--config=$env:SYSTEMDRIVE/var/lib/kubelet/config.yaml",
"--bootstrap-kubeconfig=$env:SYSTEMDRIVE/etc/kubernetes/bootstrap-kubelet.conf",
"--kubeconfig=$env:SYSTEMDRIVE/etc/kubernetes/kubelet.conf",
"--hostname-override=$(hostname)",
"--pod-infra-container-image=`"{{ pause_image }}`"",
"--enable-debugging-handlers",
"--cgroups-per-qos=false",
"--enforce-node-allocatable=`"`"",
"--resolv-conf=`"`""
{% if runtime == "docker-ee" and kubernetes_semver is version('v1.24.0', '<') %}
{% raw %}
$netId = docker network ls -f name=host --format "{{ .ID }}"
{% endraw %}
if ($netId.Length -lt 1) {
docker network create -d nat host
}
$args += "--image-pull-progress-deadline=20m",
"--network-plugin=cni"
{% endif %}
$kubeletCommandLine = "{{ kubernetes_install_path }}\kubelet.exe " + ($args -join " ") + " $kubeAdmArgs"
Invoke-Expression $kubeletCommandLine