Skip to content

Commit

Permalink
Windows 2019 support
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Paskal <[email protected]>
  • Loading branch information
maksim-paskal committed Feb 4, 2024
1 parent 5c55633 commit a7c2d61
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 137 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/chart-test.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/e2e.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/release-chart.yml

This file was deleted.

35 changes: 21 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
on:
push:
tags:
- v*
pull_request:
# push:
# tags:
# - v*

permissions:
contents: write
# permissions:
# contents: write

env:
IMAGE: paskalmaksim/aks-node-termination-handler:${{github.ref_name}}
IMAGE_LATEST: paskalmaksim/aks-node-termination-handler:latest
# IMAGE: paskalmaksim/aks-node-termination-handler:test-${{ github.run_id }}
# IMAGE_LATEST: paskalmaksim/aks-node-termination-handler:test-latest
#IMAGE: paskalmaksim/aks-node-termination-handler:${{github.ref_name}}
#IMAGE_LATEST: paskalmaksim/aks-node-termination-handler:latest
IMAGE: paskalmaksim/aks-node-termination-handler:test-${{ github.run_id }}
IMAGE_LATEST: paskalmaksim/aks-node-termination-handler:test-latest

jobs:
build:
Expand All @@ -31,7 +32,8 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --clean
args: build --clean --skip=validate --snapshot
#args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: cp Dockerfile ./dist/aks-node-termination-handler_linux_amd64_v1/Dockerfile
Expand Down Expand Up @@ -74,6 +76,9 @@ jobs:

publish-windows-amd64:
runs-on: windows-latest
strategy:
matrix:
windows-version: [ 'ltsc2019', 'ltsc2022' ]
needs: build
steps:
- uses: docker/login-action@v3
Expand All @@ -82,9 +87,9 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/download-artifact@v4
- run: tar xvf ./release/release.tar
- run: "docker build --pull --platform windows/amd64 -t ${{ env.IMAGE }}-windows-amd64 ."
- run: "docker build --build-arg WINDOWS_VERSION=${{ matrix.windows-version }} --pull --platform windows/amd64 -t ${{ env.IMAGE }}-windows-${{ matrix.windows-version }}-amd64 ."
working-directory: ./dist/aks-node-termination-handler_windows_amd64_v1
- run: docker push ${{ env.IMAGE }}-windows-amd64
- run: docker push ${{ env.IMAGE }}-windows-${{ matrix.windows-version }}-amd64

publish-manifest:
runs-on: ubuntu-latest
Expand All @@ -94,7 +99,9 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- run: docker manifest create ${{ env.IMAGE }} ${{ env.IMAGE }}-linux-amd64 ${{ env.IMAGE }}-linux-arm64 ${{ env.IMAGE }}-windows-amd64
- run: docker manifest create ${{ env.IMAGE }} ${{ env.IMAGE }}-linux-amd64 ${{ env.IMAGE }}-linux-arm64 ${{ env.IMAGE }}-windows-ltsc2022-amd64
- run: docker manifest push ${{ env.IMAGE }}
- run: docker manifest create ${{ env.IMAGE_LATEST }} ${{ env.IMAGE }}-linux-amd64 ${{ env.IMAGE }}-linux-arm64 ${{ env.IMAGE }}-windows-amd64
- run: docker manifest create ${{ env.IMAGE_LATEST }} ${{ env.IMAGE }}-linux-amd64 ${{ env.IMAGE }}-linux-arm64 ${{ env.IMAGE }}-windows-ltsc2022-amd64
- run: docker manifest push ${{ env.IMAGE_LATEST }}
- run: docker manifest create ${{ env.IMAGE_LATEST }}-ltsc2019 ${{ env.IMAGE }}-linux-amd64 ${{ env.IMAGE }}-linux-arm64 ${{ env.IMAGE }}-windows-ltsc2019-amd64
- run: docker manifest push ${{ env.IMAGE_LATEST }}-ltsc2019
19 changes: 0 additions & 19 deletions .github/workflows/test.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/validate-license.yml

This file was deleted.

4 changes: 3 additions & 1 deletion Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
ARG WINDOWS_VERSION=ltsc2022

FROM mcr.microsoft.com/windows/nanoserver:$WINDOWS_VERSION

WORKDIR /app/

Expand Down
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KUBECONFIG=$(HOME)/.kube/azure-stage
KUBECONFIG=$(HOME)/.kube/azure-test-win-cluster
tag=dev
image=paskalmaksim/aks-node-termination-handler:$(tag)
telegramToken=1072104160:AAH2sFpHELeH5oxMmd-tsVjgTuzoYO6hSLM
Expand Down Expand Up @@ -99,4 +99,17 @@ scan:
-ignore-unfixed --no-progress --severity HIGH,CRITICAL \
$(image)
@helm template ./charts/aks-node-termination-handler > /tmp/aks-node-termination-handler.yaml
@trivy config /tmp/aks-node-termination-handler.yaml
@trivy config /tmp/aks-node-termination-handler.yaml

deploy-new:
helm upgrade aks-node-termination-handler \
--install \
--namespace kube-system \
./charts/aks-node-termination-handler \
--values=values.new.yaml

helm upgrade aks-node-termination-handler-windows-2019 \
--install \
--namespace kube-system \
./charts/aks-node-termination-handler \
--values=values.old.yaml
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This tool ensures that kubernetes cluster responds appropriately to events that

Based on [Azure Scheduled Events](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/scheduled-events) and [Safely Drain a Node](https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/)

Support Linux (amd64, arm64) and Windows (amd64) nodes.
Support Linux (amd64, arm64) and Windows 2022, 2019* (amd64) nodes.

## Create Azure Kubernetes Cluster

Expand Down Expand Up @@ -53,11 +53,12 @@ az aks nodepool add \
--min-count 0 \
--max-count 10

# Create Windows nodepool with Spot Virtual Machines and autoscaling
# Create Windows (Windows Server 2022) nodepool with Spot Virtual Machines and autoscaling
az aks nodepool add \
--resource-group test-aks-group-eastus \
--cluster-name MyManagedCluster \
--os-type Windows \
--os-sku Windows2022 \
--priority Spot \
--eviction-policy Delete \
--spot-max-price -1 \
Expand All @@ -66,6 +67,20 @@ az aks nodepool add \
--min-count 1 \
--max-count 3

# Create Windows (Windows Server 2019) nodepool with Spot Virtual Machines and autoscaling
az aks nodepool add \
--resource-group test-aks-group-eastus \
--cluster-name MyManagedCluster \
--os-type Windows \
--os-sku Windows2019 \
--priority Spot \
--eviction-policy Delete \
--spot-max-price -1 \
--enable-cluster-autoscaler \
--name spot2 \
--min-count 1 \
--max-count 3

# Get config to connect to cluster
az aks get-credentials \
--resource-group test-aks-group-eastus \
Expand Down Expand Up @@ -186,3 +201,16 @@ annotations:
prometheus.io/port: "17923"
prometheus.io/scrape: "true"
```
## Windows 2019 support
If your cluster have Linux and Windows 2019 nodes, you need to use another image
```bash
helm upgrade aks-node-termination-handler \
--install \
--namespace kube-system \
aks-node-termination-handler/aks-node-termination-handler \
--set priorityClassName=system-node-critical \
--set image=paskalmaksim/aks-node-termination-handler:latest-ltsc2019
```
2 changes: 1 addition & 1 deletion charts/aks-node-termination-handler/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
icon: https://helm.sh/img/helm.svg
name: aks-node-termination-handler
version: 1.1.3
version: 1.1.4
description: Gracefully handle Azure Virtual Machines shutdown within Kubernetes
maintainers:
- name: maksim-paskal # Maksim Paskal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.configMap.name }}
name: {{ tpl .Values.configMap.name . }}
data:
{{ toYaml .Values.configMap.data | indent 2 }}
{{ end }}
16 changes: 10 additions & 6 deletions charts/aks-node-termination-handler/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: aks-node-termination-handler
name: {{ .Release.Name }}
labels:
app: aks-node-termination-handler
app: {{ .Release.Name }}
spec:
selector:
matchLabels:
app: aks-node-termination-handler
app: {{ .Release.Name }}
template:
metadata:
annotations:
Expand All @@ -19,12 +19,12 @@ spec:
{{ toYaml .Values.annotations | indent 8 }}
{{ end }}
labels:
app: aks-node-termination-handler
app: {{ .Release.Name }}
{{ if .Values.labels }}
{{ toYaml .Values.labels | indent 8 }}
{{ end }}
spec:
serviceAccount: aks-node-termination-handler
serviceAccount: {{ .Release.Name }}
{{ if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{ end }}
Expand All @@ -35,11 +35,15 @@ spec:
{{- if .Values.nodeSelector}}
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
{{- end }}
volumes:
- name: files
configMap:
name: {{ .Values.configMap.name }}
name: {{ tpl .Values.configMap.name . }}
{{ if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{ end }}
Expand Down
10 changes: 5 additions & 5 deletions charts/aks-node-termination-handler/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: aks-node-termination-handler
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: aks-node-termination-handler
name: {{ .Release.Name }}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -53,12 +53,12 @@ rules:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: aks-node-termination-handler
name: {{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: aks-node-termination-handler
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: aks-node-termination-handler
name: {{ .Release.Name }}
apiGroup: rbac.authorization.k8s.io
4 changes: 3 additions & 1 deletion charts/aks-node-termination-handler/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ labels: {}

configMap:
create: true
name: aks-node-termination-handler-files
name: "{{ .Release.Name }}-files"
mountPath: /files
data: {}
# slack-payload.json: |
Expand Down Expand Up @@ -40,6 +40,8 @@ securityContext:
windowsOptions:
runAsUserName: "ContainerUser"

affinity: {}

tolerations:
- key: "kubernetes.azure.com/scalesetpriority"
operator: "Equal"
Expand Down
Loading

0 comments on commit a7c2d61

Please sign in to comment.