-
Notifications
You must be signed in to change notification settings - Fork 9
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 #30 from stackhpc/feat/autoscaler-service-account
Replaced mounted kubeconfig with service account
- Loading branch information
Showing
9 changed files
with
51 additions
and
33 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
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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
#!/usr/bin/bash | ||
|
||
export KUBECONFIG=/var/lib/slurmctld/kubeconfig | ||
echo "$(date) Resume invoked $0 $*" &>> /var/log/slurm/power_save.log | ||
|
||
echo "$(date) Resume invoked $0 $*" >> /var/log/slurm/power_save.log | ||
APISERVER=https://kubernetes.default.svc | ||
SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount | ||
NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace) | ||
TOKEN=$(cat ${SERVICEACCOUNT}/token) | ||
CACERT=${SERVICEACCOUNT}/ca.crt | ||
|
||
hosts=$(scontrol show hostnames $1) # this is purely a textual expansion, doens't depend on defined nodes | ||
for host in $hosts | ||
do | ||
sed s/SLURMD_NODENAME/$host/ /etc/slurm/slurmd-pod-template.yml | kubectl create -f - | ||
done | ||
( sed s/SLURMD_NODENAME/$host/ /etc/slurm/slurmd-pod-template.yml | \ | ||
kubectl --server $APISERVER --token $TOKEN --certificate-authority $CACERT create -f - ) | ||
done |
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
#!/usr/bin/bash | ||
|
||
export KUBECONFIG=/var/lib/slurmctld/kubeconfig | ||
|
||
echo "$(date) Suspend invoked $0 $*" >> /var/log/slurm/power_save.log | ||
|
||
APISERVER=https://kubernetes.default.svc | ||
SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount | ||
NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace) | ||
TOKEN=$(cat ${SERVICEACCOUNT}/token) | ||
CACERT=${SERVICEACCOUNT}/ca.crt | ||
|
||
hosts=$(scontrol show hostnames $1) # this is purely a textual expansion, doens't depend on defined nodes | ||
for host in $hosts | ||
do | ||
kubectl delete pod $host | ||
kubectl --server $APISERVER --token $TOKEN --certificate-authority $CACERT delete pod $host | ||
done |
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
slurm-cluster-chart/templates/slurm-autoscaler-service-account.yaml
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: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: slurm-autoscaler-account | ||
automountServiceAccountToken: True | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: slurm-autoscaler-role | ||
rules: | ||
- apiGroups: [""] # "" indicates the core API group | ||
resources: ["pods"] | ||
verbs: ["get","apply","create", "patch", "delete", "list", "watch"] | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: slurm-autoscaler-rolebinding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: slurm-autoscaler-account | ||
roleRef: | ||
kind: Role | ||
name: slurm-autoscaler-role | ||
apiGroup: rbac.authorization.k8s.io |
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