diff --git a/Dockerfile b/Dockerfile index 18ca1a2..b64dec0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,10 @@ -FROM python:3-slim-stretch +FROM python:3-alpine ARG VERSION=undefined ENV VERSION ${VERSION} # Install curl and certificates -RUN apt-get update && apt-get install -y --no-install-recommends \ - curl \ - openssl \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* +RUN apk add --no-cache curl openssl ca-certificates # Install kubectl RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \ diff --git a/Makefile b/Makefile index ea019e4..d74cd2d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ VERSION := $(shell git describe --always --dirty --tags 2>/dev/null || echo "undefined") -IMG ?= quay.io/pusher/k8s-spot-termination-handler +IMG ?= quay.io/cogentwebworks/k8s-spot-termination-handler RED := \033[31m GREEN := \033[32m diff --git a/deploy/clusterrole.yaml b/deploy/clusterrole.yaml index 7620694..2f63e6c 100644 --- a/deploy/clusterrole.yaml +++ b/deploy/clusterrole.yaml @@ -12,6 +12,7 @@ rules: verbs: - get - update + - patch - apiGroups: - "" resources: diff --git a/deploy/daemonset.yaml b/deploy/daemonset.yaml index 61e6c63..3acc3e7 100644 --- a/deploy/daemonset.yaml +++ b/deploy/daemonset.yaml @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: DaemonSet metadata: name: k8s-spot-termination-handler @@ -6,17 +6,20 @@ metadata: labels: app: k8s-spot-termination-handler spec: + selector: + matchLabels: + app: k8s-spot-termination-handler template: metadata: name: k8s-spot-termination-handler labels: app: k8s-spot-termination-handler spec: - # Uncomment the following line if using RBAC - # serviceAccountName: k8s-spot-termination-handler + # comment the following line if not using RBAC + serviceAccountName: k8s-spot-termination-handler containers: - name: k8s-spot-termination-handler - image: quay.io/pusher/k8s-spot-termination-handler:v0.1.0 + image: quay.io/cogentwebworks/k8s-spot-termination-handler:v0.4 imagePullPolicy: IfNotPresent env: - name: NODE_NAME diff --git a/docker_entrypoint.py b/docker_entrypoint.py index 395df21..ebd02f4 100644 --- a/docker_entrypoint.py +++ b/docker_entrypoint.py @@ -32,7 +32,8 @@ def main(): if result == 0: print('Node Drain successful') break - + # Sleep so we do not restart before drain evicts this pod. + sleep(120) else: if counter == 60: counter = 0 diff --git a/requirements.txt b/requirements.txt index 6f910cb..6fd9285 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -flake8==3.6.0 -pylint==2.3.1 -requests==2.21.0 -urllib3<1.25,>=1.21.1 +flake8==3.8.3 +pylint==2.5.3 +requests==2.24.0 +urllib3==1.25.10