-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for GPU instance groups (#6)
* Add support for GPU instance groups * Install nvidia drivers * Fix error handling in wait-for-kops. Fix patching so that it overwrites. * add nvidia-docker-installer.sh script * Upgrade geodesic. Fix wait-for-kops formatting. * Upgrade docker-ce for docker-nvidia compatibility * verbose bash execution * reduce default size back to zero
- Loading branch information
Showing
12 changed files
with
582 additions
and
5 deletions.
There are no files selected for viewing
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
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
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,237 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
app: cluster-autoscaler | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRole | ||
metadata: | ||
name: cluster-autoscaler | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
app: cluster-autoscaler | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
- endpoints | ||
verbs: | ||
- create | ||
- patch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods/eviction | ||
verbs: | ||
- create | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods/status | ||
verbs: | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- endpoints | ||
resourceNames: | ||
- cluster-autoscaler | ||
verbs: | ||
- get | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
verbs: | ||
- watch | ||
- list | ||
- get | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- services | ||
- replicationcontrollers | ||
- persistentvolumeclaims | ||
- persistentvolumes | ||
verbs: | ||
- watch | ||
- list | ||
- get | ||
- apiGroups: | ||
- extensions | ||
resources: | ||
- replicasets | ||
- daemonsets | ||
verbs: | ||
- watch | ||
- list | ||
- get | ||
- apiGroups: | ||
- policy | ||
resources: | ||
- poddisruptionbudgets | ||
verbs: | ||
- watch | ||
- list | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- statefulsets | ||
verbs: | ||
- watch | ||
- list | ||
- get | ||
- apiGroups: | ||
- storage.k8s.io | ||
resources: | ||
- storageclasses | ||
verbs: | ||
- watch | ||
- list | ||
- get | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: Role | ||
metadata: | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
app: cluster-autoscaler | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- create | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
resourceNames: | ||
- cluster-autoscaler-status | ||
verbs: | ||
- delete | ||
- get | ||
- update | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: cluster-autoscaler | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
app: cluster-autoscaler | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-autoscaler | ||
subjects: | ||
- kind: ServiceAccount | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: RoleBinding | ||
metadata: | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
app: cluster-autoscaler | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: cluster-autoscaler | ||
subjects: | ||
- kind: ServiceAccount | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
|
||
--- | ||
|
||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
app: cluster-autoscaler | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: cluster-autoscaler | ||
template: | ||
metadata: | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
app: cluster-autoscaler | ||
annotations: | ||
# For 1.6, we keep the old tolerations in case of a downgrade to 1.5 | ||
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"dedicated", "value":"master"}]' | ||
prometheus.io/scrape: 'true' | ||
prometheus.io/port: '8085' | ||
spec: | ||
tolerations: | ||
- effect: NoSchedule | ||
key: node-role.kubernetes.io/master | ||
nodeSelector: | ||
kubernetes.io/role: master | ||
serviceAccountName: cluster-autoscaler | ||
containers: | ||
- name: cluster-autoscaler | ||
image: '{{ getenv "IMAGE" | default "k8s.gcr.io/cluster-autoscaler:v1.2.0" }}' | ||
livenessProbe: | ||
httpGet: | ||
path: /health-check | ||
port: 8085 | ||
readinessProbe: | ||
httpGet: | ||
path: /health-check | ||
port: 8085 | ||
resources: | ||
limits: | ||
cpu: 100m | ||
memory: 300Mi | ||
requests: | ||
cpu: 100m | ||
memory: 300Mi | ||
command: | ||
- ./cluster-autoscaler | ||
- --v=4 | ||
- --stderrthreshold=info | ||
- --cloud-provider={{ getenv "CLOUD_PROVIDER" | default "aws" }} | ||
- --scale-down-delay-after-add={{ getenv "GPU_SCALE_DOWN_DELAY_AFTER_ADD" | default "30m" }} | ||
- --scale-down-delay-after-delete={{ getenv "GPU_SCALE_DOWN_DELAY_AFTER_DELETE" | default "10m" }} | ||
- --skip-nodes-with-local-storage=false | ||
- --nodes={{ getenv "GPU_MIN_NODES" | default "0" }}:{{ getenv "GPU_MAX_NODES" | default "2" }}:{{ getenv "GPU_GROUP_NAME" | default "gpu-nodes" }}.{{getenv "KOPS_CLUSTER_NAME"}} | ||
env: | ||
- name: AWS_REGION | ||
value: {{ getenv "AWS_REGION" }} | ||
volumeMounts: | ||
- name: ssl-certs | ||
mountPath: "/etc/ssl/certs/ca-certificates.crt" | ||
readOnly: true | ||
volumes: | ||
- name: ssl-certs | ||
hostPath: | ||
path: "/etc/ssl/certs/ca-certificates.crt" | ||
dnsPolicy: "Default" |
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,41 @@ | ||
# Based on https://github.com/NVIDIA/k8s-device-plugin | ||
apiVersion: extensions/v1beta1 | ||
kind: DaemonSet | ||
metadata: | ||
name: nvidia-device-plugin | ||
namespace: kube-system | ||
spec: | ||
template: | ||
metadata: | ||
# Mark this pod as a critical add-on; when enabled, the critical add-on scheduler | ||
# reserves resources for critical add-on pods so that they can be rescheduled after | ||
# a failure. This annotation works in tandem with the toleration below. | ||
annotations: | ||
scheduler.alpha.kubernetes.io/critical-pod: "" | ||
labels: | ||
name: nvidia-device-plugin | ||
spec: | ||
nodeSelector: | ||
kops.k8s.io/instancegroup: gpu-nodes | ||
tolerations: | ||
# Allow this pod to be rescheduled while the node is in "critical add-ons only" mode. | ||
# This, along with the annotation above marks this pod as a critical add-on. | ||
- key: CriticalAddonsOnly | ||
operator: Exists | ||
- key: nvidia.com/gpu | ||
operator: Exists | ||
effect: NoSchedule | ||
containers: | ||
- image: nvidia/k8s-device-plugin:1.9 | ||
name: nvidia-device-plugin-ctr | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: ["ALL"] | ||
volumeMounts: | ||
- name: device-plugin | ||
mountPath: /var/lib/kubelet/device-plugins | ||
volumes: | ||
- name: device-plugin | ||
hostPath: | ||
path: /var/lib/kubelet/device-plugins |
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,18 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "nvidia-test" | ||
spec: | ||
restartPolicy: "OnFailure" | ||
nodeSelector: | ||
beta.kubernetes.io/instance-type: "p2.xlarge" | ||
tolerations: | ||
- key: "nvidia.com/gpu" | ||
effect: "NoSchedule" | ||
containers: | ||
- name: "cuda-vector-add" | ||
# https://github.com/kubernetes/kubernetes/blob/v1.7.11/test/images/nvidia-cuda/Dockerfile | ||
image: "k8s.gcr.io/cuda-vector-add:v0.1" | ||
resources: | ||
limits: | ||
nvidia.com/gpu: 1 |
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,29 @@ | ||
spec: | ||
docker: | ||
logDriver: json-file | ||
version: 17.03.2 | ||
additionalPolicies: | ||
nodes: | | ||
[ | ||
{ | ||
"Sid": "assumeClusterRole", | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Resource": ["*"] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"autoscaling:DescribeAutoScalingGroups", | ||
"autoscaling:DescribeAutoScalingInstances", | ||
"autoscaling:DescribeTags", | ||
"autoscaling:DescribeLaunchConfigurations", | ||
"autoscaling:SetDesiredCapacity", | ||
"autoscaling:TerminateInstanceInAutoScalingGroup", | ||
"ec2:DescribeLaunchTemplateVersions" | ||
], | ||
"Resource": "*" | ||
} | ||
] |
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,19 @@ | ||
spec: | ||
machineType: p2.xlarge | ||
taints: | ||
- nvidia.com/gpu=:NoSchedule | ||
hooks: | ||
# Before is just advisory; `docker-healthcheck.service` appears to get started by `kops-configuration.service` | ||
- before: | ||
- docker.service | ||
- docker-healthcheck.service | ||
manifest: | | ||
Type=oneshot | ||
ExecStart=/bin/bash -c '/usr/bin/curl -L -S -f https://raw.githubusercontent.com/vanvalenlab/kiosk/gpus/scripts/nvidia-docker-installer.sh | /bin/bash -x' | ||
name: nvidia-docker-install.service | ||
minSize: 0 | ||
maxSize: 2 | ||
# https://github.com/kubernetes/autoscaler/issues/903#issuecomment-392885606 | ||
kubelet: | ||
featureGates: | ||
DevicePlugins: "true" |
Oops, something went wrong.