-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from kinderyj/main
init tke-spot-agent
- Loading branch information
Showing
7 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: v2 | ||
name: tke-spot-agent | ||
description: A Helm chart for the-spot-agent | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 1.0.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
appVersion: 1.0.0 | ||
|
||
maintainers: | ||
- name: yujunwang | ||
email: [email protected] | ||
|
||
icon: https://github.com/tkestack/charts/raw/main/icons/tke-spot-agent.png | ||
home: https://github.com/tkestack/charts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Helm chart for tke-spot-agent | ||
|
||
# Overview | ||
|
||
With this chart you are going to install the tke-spot-agent. This agent can watch the spot instance metadata on ecah node. | ||
When the spot node will be deleted by cloud provider, the tke-spot-agent can catch the spot instance interuption metadata in advance(2 minutes), and | ||
disable this node to prevent new pod to be scheduled to this node, and then drain the pod on this node. | ||
|
||
# Prerequisites | ||
|
||
* Kubernetes >= v1.11 | ||
|
||
## Configuration | ||
|
||
All configuration settings are contained and described in | ||
[values.yaml](tke-spot-agent/values.yaml). | ||
|
||
| Parameter | Description | Default | | ||
| --- | --- | --- | | ||
| `env.DISABLE_ONLY` | If true, will disable the node only, will not drain the pod. | `false` | | ||
| `env.DELETE_EMPTY_LOCAL_DIR` | If ture, will force to delete the pod with empty local dir. | `true` | | ||
| `env.TAINT` | If true, will only taint the node and make the node as unschedulable, but don't drain the pod. | `false` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "tke-spot-agent.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "tke-spot-agent.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "tke-spot-agent.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "tke-spot-agent.labels" -}} | ||
helm.sh/chart: {{ include "tke-spot-agent.chart" . }} | ||
{{ include "tke-spot-agent.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "tke-spot-agent.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "tke-spot-agent.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "tke-spot-agent.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "tke-spot-agent.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: tke-spot-agent | ||
namespace: kube-system | ||
labels: | ||
app.kubernetes.io/name: tke-spot-agent | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: tke-spot-agent | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
verbs: | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
verbs: | ||
- list | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods/eviction | ||
verbs: | ||
- create | ||
- apiGroups: | ||
- extensions | ||
resources: | ||
- daemonsets | ||
verbs: | ||
- get | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- daemonsets | ||
verbs: | ||
- get | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: tke-spot-agent | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tke-spot-agent | ||
namespace: kube-system | ||
roleRef: | ||
kind: ClusterRole | ||
name: tke-spot-agent | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: tke-spot-agent | ||
namespace: kube-system | ||
labels: | ||
k8s-app: tke-spot-agent | ||
spec: | ||
updateStrategy: | ||
rollingUpdate: | ||
maxUnavailable: 5 | ||
type: RollingUpdate | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: tke-spot-agent | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: tke-spot-agent | ||
spec: | ||
volumes: | ||
- name: "uptime" | ||
hostPath: | ||
path: "/proc/uptime" | ||
serviceAccountName: tke-spot-agent | ||
hostNetwork: true | ||
dnsPolicy: "ClusterFirstWithHostNet" | ||
containers: | ||
- name: tke-spot-agent | ||
image: {{ .Values.image.repository }}:{{.Values.image.tag}} | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
securityContext: | ||
readOnlyRootFilesystem: true | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
allowPrivilegeEscalation: false | ||
volumeMounts: | ||
- name: "uptime" | ||
mountPath: "/proc/uptime" | ||
readOnly: true | ||
env: | ||
- name: SPOT_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
- name: DISABLE_ONLY | ||
value: "{{ .Values.env.DISABLE_ONLY }}" | ||
- name: TAINT | ||
value: "{{ .Values.env.TAINT }}" | ||
- name: DEBUG_MODE | ||
value: "false" | ||
- name: DELETE_EMPTY_LOCAL_DIR | ||
value: "{{ .Values.env.DELETE_EMPTY_LOCAL_DIR }}" | ||
resources: | ||
limits: | ||
cpu: 100m | ||
memory: 128Mi | ||
requests: | ||
cpu: 10m | ||
memory: 8Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Default values for tke-spot-agent. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
image: | ||
repository: ccr.ccs.tencentyun.com/tke-market/tke-spot-agent | ||
tag: v1.0 | ||
pullPolicy: IfNotPresent | ||
# Overrides the image tag whose default is the chart version. | ||
|
||
env: | ||
# DISABLE_ONLY controls whether to drain the pod or not when spot instances will be retrieved. | ||
# If true, will disable the node only, will not drain the pod. | ||
DISABLE_ONLY: "false" | ||
# By Default, the Kubernetes `drain` will not delete the pod with empty local dir, so DELETE_EMPTY_LOCAL_DIR=true | ||
# will force to delete the pod with empty local dir. | ||
DELETE_EMPTY_LOCAL_DIR: "true" | ||
# When TAINT is ture, it will only taint the node(tke.cloud.tencent.com/tke-spot-agent) and make | ||
# the node as unschedulable, but will not drain the pod. | ||
TAINT: "false" | ||
|
||
|
||
|