Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit fc6b7ea

Browse files
authored
Refactor the install (#12)
* Refactor the install Fixes https://github.com/kf5i/k3ai/issues/11. * Refactor the install Fixes https://github.com/kf5i/k3ai/issues/11. * Add management plung * Add management plung
1 parent d55099e commit fc6b7ea

File tree

1 file changed

+164
-72
lines changed

1 file changed

+164
-72
lines changed

install

Lines changed: 164 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#!/bin/bash
2+
3+
#########################################
4+
### K3ai (keɪ3ai)
5+
### https://github.com/kf5i/k3ai
6+
### Alessandro Festa @bringyourownai
7+
### Gabriele Santomaggio @gsantomaggio
8+
#########################################
9+
210
info()
311
{
412
echo '[INFO] ' "$@"
@@ -41,88 +49,172 @@ while [ : ]
4149
done
4250
}
4351

52+
kubeflow_install_pipelines(){
53+
info "Installing pipelines crd"
54+
export PIPELINE_VERSION=1.0.1
55+
kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/cluster-scoped-resources?ref=$PIPELINE_VERSION"
56+
kubectl wait --for condition=established --timeout=60s crd/applications.app.k8s.io
57+
sleep_cursor &
58+
info "Installing pipelines manifests"
59+
kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/platform-agnostic-pns?ref=$PIPELINE_VERSION"
60+
61+
waiting_pod_array=("k8s-app=kube-dns;kube-system"
62+
"k8s-app=metrics-server;kube-system"
63+
"app=traefik;kube-system"
64+
"app=minio;kubeflow"
65+
"app=mysql;kubeflow"
66+
"app=cache-server;kubeflow"
67+
"app=ml-pipeline-persistenceagent;kubeflow"
68+
"component=metadata-grpc-server;kubeflow"
69+
"app=ml-pipeline-ui;kubeflow")
70+
71+
for i in "${waiting_pod_array[@]}"; do
72+
echo "$i";
73+
IFS=';' read -ra VALUES <<< "$i"
74+
wait "${VALUES[0]}" "${VALUES[1]}"
75+
done
76+
77+
78+
79+
info "Kubeflow pipelines ready!!"
80+
81+
info "Defining the ingress"
82+
sleep_cursor
83+
84+
kubectl apply -f - << EOF
85+
apiVersion: networking.k8s.io/v1beta1
86+
kind: IngressClass
87+
metadata:
88+
name: traefik-lb
89+
spec:
90+
controller: traefik.io/ingress-controller
91+
EOF
4492

45-
if [ $1 = "--gpu" ]
46-
then
47-
info "Install Pipelines with GPU support, docker as runtime"
48-
curl -sfL https://get.k3s.io | sh -s - --docker --kubelet-arg="feature-gates=DevicePlugins=true" --write-kubeconfig-mode 644
49-
#### GPU Support
50-
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.7.0/nvidia-device-plugin.yml
51-
else
52-
info "Install Pipelines without GPU support, containerd as runtime"
53-
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
54-
fi
55-
56-
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
57-
58-
info "Installing pipelines crd"
59-
export PIPELINE_VERSION=1.0.1
60-
kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/cluster-scoped-resources?ref=$PIPELINE_VERSION"
61-
kubectl wait --for condition=established --timeout=60s crd/applications.app.k8s.io
62-
sleep_cursor &
63-
info "Installing pipelines manifests"
64-
kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/platform-agnostic-pns?ref=$PIPELINE_VERSION"
65-
66-
waiting_pod_array=("k8s-app=kube-dns;kube-system"
67-
"k8s-app=metrics-server;kube-system"
68-
"app=traefik;kube-system"
69-
"app=minio;kubeflow"
70-
"app=mysql;kubeflow"
71-
"app=cache-server;kubeflow"
72-
"app=ml-pipeline-persistenceagent;kubeflow"
73-
"component=metadata-grpc-server;kubeflow"
74-
"app=ml-pipeline-ui;kubeflow")
75-
76-
for i in "${waiting_pod_array[@]}"; do
77-
echo "$i";
78-
IFS=';' read -ra VALUES <<< "$i"
79-
wait "${VALUES[0]}" "${VALUES[1]}"
80-
done
93+
kubectl apply -f - << EOF
94+
apiVersion: "networking.k8s.io/v1beta1"
95+
kind: "Ingress"
96+
metadata:
97+
name: "pipeline-ingress"
98+
namespace: kubeflow
99+
annotations:
100+
nginx.ingress.kubernetes.io/rewrite-target: /$2
101+
102+
spec:
103+
ingressClassName: "traefik-lb"
104+
rules:
105+
- http:
106+
paths:
107+
- path: "/"
108+
backend:
109+
serviceName: "ml-pipeline-ui"
110+
servicePort: 80
111+
EOF
81112

113+
sleep_cursor
82114

115+
IP=$(kubectl get service/traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}' -n kube-system)
116+
info "pipelines UI: http://"$IP
117+
}
83118

84-
info "Kubeflow pipelines ready!!"
119+
##################
120+
INTERNAL_INSTALL_K3S_EXEC=""
85121

86-
info "Defining the ingress"
87-
sleep_cursor
88122

89-
kubectl apply -f - << EOF
90-
apiVersion: networking.k8s.io/v1beta1
91-
kind: IngressClass
92-
metadata:
93-
name: traefik-lb
94-
spec:
95-
controller: traefik.io/ingress-controller
96-
EOF
123+
k3s_install_service()
124+
{
125+
info "Installing k3s service with the following parameters:" "${INSTALL_K3S_EXEC} ${INTERNAL_INSTALL_K3S_EXEC}"
126+
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="${INSTALL_K3S_EXEC} ${INTERNAL_INSTALL_K3S_EXEC}" sh -s -
127+
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
128+
}
97129

98-
kubectl apply -f - << EOF
99-
apiVersion: "networking.k8s.io/v1beta1"
100-
kind: "Ingress"
101-
metadata:
102-
name: "example-ingress"
103-
namespace: kubeflow
104-
annotations:
105-
nginx.ingress.kubernetes.io/rewrite-target: /$2
106-
107-
spec:
108-
ingressClassName: "traefik-lb"
109-
rules:
110-
- http:
111-
paths:
112-
- path: "/"
113-
backend:
114-
serviceName: "ml-pipeline-ui"
115-
servicePort: 80
116-
EOF
130+
k3s_install_service_gpu()
131+
{
132+
info "Installing the GPU Support on docker"
133+
INTERNAL_INSTALL_K3S_EXEC="--docker"
134+
k3s_install_service
135+
#### GPU Support
136+
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.7.0/nvidia-device-plugin.yml
137+
}
117138

118-
sleep_cursor
119139

120-
info "K3s AI ready!!"
140+
default_installation(){
141+
info "Installing pipelines"
142+
k3s_install_service
143+
kubeflow_install_pipelines
144+
}
145+
146+
147+
manage_plugin(){
148+
PLUGIN=$1
149+
PLUGIN="${PLUGIN:2}"
150+
info "Installing plugin: " $PLUGIN
151+
info "URL:" https://raw.githubusercontent.com/kf5i/k3ai-plugins/main/$PLUGIN/install
152+
curl -sfL https://raw.githubusercontent.com/kf5i/k3ai-plugins/main/$PLUGIN/install | bash -s -
153+
}
154+
155+
156+
manage() {
157+
### DEFAULT == --cpu and --pipelines
158+
# if [[ "$#" -eq 0 ]]; then
159+
# kubeflow_install_pipelines
160+
# fi
161+
while [[ "$#" -ne 0 ]]; do
162+
case "$1" in
163+
"--pipelines")
164+
kubeflow_install_pipelines
165+
shift 1
166+
;;
167+
--plugin*)
168+
info "Installing plugin:" "$1"
169+
manage_plugin "$1"
170+
shift 1
171+
;;
172+
*)
173+
shift 1
174+
;;
175+
esac
176+
done
177+
}
178+
121179

122-
info "To use kubectl: export KUBECONFIG=/etc/rancher/k3s/k3s.yaml"
123-
info "or you can use k3s kubectl "
180+
181+
182+
main() {
183+
### DEFAULT == --cpu and --pipelines
184+
if [[ "$#" -eq 0 ]]; then
185+
default_installation
186+
fi
187+
OR="$@"
188+
while [[ "$#" -ne 0 ]]; do
189+
case "$1" in
190+
"--gpu")
191+
k3s_install_service_gpu
192+
manage $OR
193+
shift 1
194+
;;
195+
"--cpu")
196+
info "Installing the CPU Support"
197+
k3s_install_service
198+
manage $OR
199+
shift 1
200+
;;
201+
"--skipk3s")
202+
info "Skip Installation Server"
203+
manage $OR
204+
shift 1
205+
;;
206+
207+
*)
208+
shift 1
209+
;;
210+
esac
211+
done
212+
}
213+
214+
main "$@"
215+
216+
217+
info "K3ai setup finished"
124218
info "k3s-uninstall.sh to uninstall"
125219

126-
IP=$(kubectl get service/traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}' -n kube-system)
127-
info "pipelines UI: http://"$IP
128220

0 commit comments

Comments
 (0)