Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #369 from dweomer/deprecate-upgrade-scripts
Browse files Browse the repository at this point in the history
deprecate upgrade scripts in favor of upgrade controller
  • Loading branch information
dweomer authored Jan 31, 2020
2 parents 5e18d14 + 2e1365e commit 27e0740
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ data:
SYSTEM_UPGRADE_CONTROLLER_THREADS: "2"
SYSTEM_UPGRADE_JOB_ACTIVE_DEADLINE_SECONDS: "900"
SYSTEM_UPGRADE_JOB_BACKOFF_LIMIT: "2"
SYSTEM_UPGRADE_JOB_IMAGE_PULL_POLICY: "IfNotPresent"
SYSTEM_UPGRADE_JOB_KUBECTL_IMAGE: "rancher/kubectl:v1.17.0"
SYSTEM_UPGRADE_JOB_PRIVILEGED: "true"
SYSTEM_UPGRADE_PLAN_POLLING_INTERVAL: "15m"
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -50,14 +52,21 @@ spec:
labels:
upgrade.cattle.io/controller: system-upgrade-controller # necessary to avoid drain
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- {key: "node-role.kubernetes.io/master", operator: In, values: ["true"]}
serviceAccountName: k3os-upgrade
tolerations:
- key: "node.kubernetes.io/unschedulable" # necessary to avoid cordon/drain
operator: "Exists"
effect: "NoSchedule"
containers:
- name: system-upgrade-controller
image: rancher/system-upgrade-controller:v0.1.0
image: rancher/system-upgrade-controller:v0.2.0
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: default-controller-env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ metadata:
spec:
# The maximum number of concurrent nodes to apply this update on.
concurrency: 1

# The value for `channel` is assumed to be a URL that returns HTTP 302 with the last path element of the value
# returned in the Location header assumed to be an image tag.
# SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/upgrade/plan/plan.go#L177
channel: https://github.com/rancher/k3os/releases/latest

# Providing a value for `version` will prevent polling/resolution of the `channel` if specified.
# version: v0.9.0-dev

# Select which nodes this plan can be applied to.
nodeSelector:
matchExpressions:
# This limits application of this upgrade only to nodes that have opted in by applying this label.
Expand All @@ -28,11 +32,25 @@ spec:
- {key: k3os.io/mode, operator: Exists}
# Additionally, do not attempt to upgrade nodes booted from "live" CDROM.
- {key: k3os.io/mode, operator: NotIn, values: ["live"]}

# The service account for the pod to use. As with normal pods, if not specified the `default` service account from the namespace will be assigned.
# See https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
serviceAccountName: k3os-upgrade

# The prepare init container is run before cordon/drain which is run before the upgrade container.
# Shares the same format as the `upgrade` container
# prepare:
# image: alpine:3.11
# command: [sh, -c]
# args: [" echo '### ENV ###'; env | sort; echo '### RUN ###'; find /run/system-upgrade | sort"]
# SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/apis/upgrade.cattle.io/v1/types.go#L58

# See https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/#use-kubectl-drain-to-remove-a-node-from-service
drain:
# deleteLocalData: true
# ignoreDaemonSets: true
force: true

# SEE https://github.com/rancher/system-upgrade-controller/blob/v0.1.0/pkg/apis/upgrade.cattle.io/v1/types.go#L51
upgrade:
# The tag portion of the image will be overridden with the value from `.status.latestVersion` a.k.a. the resolved version.
Expand Down
6 changes: 6 additions & 0 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ docker build \
--build-arg VERSION=${VERSION} \
--file package/Dockerfile \
--tag ${REPO}/k3os:${TAG} \
--tag ${REPO}/k3os:latest \
.
docker image save --output ./dist/images.tar \
${REPO}/k3os:${TAG} \
${REPO}/k3os:latest
echo ${REPO}/k3os:${TAG} > ./dist/images.txt
echo Built ${REPO}/k3os:${TAG}
5 changes: 2 additions & 3 deletions scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="${COMMIT}${DIRTY}"
VERSION="$(git describe --always --tags)${DIRTY}"
fi

if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi

ARCH=${ARCH:-"amd64"}
SUFFIX="-${ARCH}"
TAG=${TAG:-${VERSION}${SUFFIX}}
TAG=${TAG:-"${VERSION}-${ARCH}"}
REPO=${REPO:-rancher}

if echo $TAG | grep -q dirty; then
Expand Down

0 comments on commit 27e0740

Please sign in to comment.