-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (74 loc) · 2.94 KB
/
cache-image.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Cache image
on:
workflow_dispatch:
inputs:
containers:
description: Container(s) to cache (comma-separated)
required: true
jobs:
deploywrappers:
name: Deploy DaemonSet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Helm
run: curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: save kubeconfig
shell: bash
run: mkdir -p ~/.kube && echo "${{ secrets.TEST_KUBECONFIG }}" > ~/.kube/config
- name: 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" && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl && kubectl version
- name: Deploy DaemonSet
run: |
cat << "EOF" > ds-template.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: PLACEHOLDERNAME-cache-daemonset
namespace: cache-gxy
spec:
selector:
matchLabels:
name: PLACEHOLDERNAME-cache
template:
metadata:
labels:
name: PLACEHOLDERNAME-cache
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: bioconductor.org/type
operator: In
values: ["worker"]
containers:
- name: PLACEHOLDERNAME-cache
image: PLACEHOLDERCONTAINER
resources:
limits:
cpu: 10m
memory: 10Mi
requests:
cpu: 5m
memory: 5Mi
command:
- /bin/sh
args:
- "-c"
- "sleep 604800"
terminationGracePeriodSeconds: 1
EOF
cat << "EOF" > /tmp/create-ds.sh
IFS=',' read -ra CONTAINERS <<< "$1"
for CONTAINER in "${CONTAINERS[@]}"; do
NAME=$(echo "$CONTAINER" | sed "s/[^[:alnum:]-]//g")
cp ds-template.yaml "$NAME-ds-template.yaml"
sed -i "s#PLACEHOLDERNAME#$NAME#g" $NAME-ds-template.yaml
sed -i "s#PLACEHOLDERCONTAINER#$CONTAINER#g" $NAME-ds-template.yaml
sed -i "s#PLACEHOLDERNODES#$(kubectl get nodes -o custom-columns='NAME:.metadata.name' --no-headers | grep 'cluster-' | awk '{printf "\"%s\",", $1}' | sed 's/,$//')#g" $NAME-ds-template.yaml
kubectl apply -f $NAME-ds-template.yaml
done
EOF
bash /tmp/create-ds.sh '${{inputs.containers}}'