Skip to content

Commit 57d7ebd

Browse files
committed
automlops workflow
1 parent bc31d05 commit 57d7ebd

9 files changed

+14153
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# helm apps
2+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
3+
# helm repo add influxdata https://helm.influxdata.com
4+
helm repo add grafana https://grafana.github.io/helm-charts
5+
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
6+
helm repo add traefik https://traefik.github.io/charts
7+
helm repo add community-charts https://community-charts.github.io/helm-charts
8+
helm repo add minio-helm https://charts.min.io/
9+
helm add repo bitnami https://charts.bitnami.com/bitnami
10+
helm repo add cowboysysop https://cowboysysop.github.io/charts/
11+
helm repo update
12+
13+
# helm install my-release oci://ghcr.io/cowboysysop/charts/flowise
14+
helm install flowise cowboysysop/flowise -n flowise --create-namespace
15+
16+
## create default storageclass
17+
kubectl patch storageclass nfs-client -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
18+
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
19+
20+
# argo
21+
myNameSpaceArgo=argo
22+
kubectl get namespace | grep -q "^$myNameSpaceArgo " || kubectl create namespace $myNameSpaceArgo
23+
kubectl -n $myNameSpaceArgo apply -f ./quick-start-minimal-v3.6.5.yaml
24+
kubectl -n $myNameSpaceArgo create rolebinding default-admin --clusterrole=admin --serviceaccount=argo:default
25+
kubectl -n argo patch svc argo-server -p '{"spec": {"type": "LoadBalancer"}}'
26+
27+
# disable https and security by server mode
28+
kubectl patch deployment \
29+
argo-server \
30+
--namespace argo \
31+
--type='json' \
32+
-p='[{"op": "replace", "path": "/spec/template/spec/containers/0/args", "value": [
33+
"server",
34+
"--auth-mode=server",
35+
"--secure=false"
36+
]},
37+
{"op": "replace", "path": "/spec/template/spec/containers/0/readinessProbe/httpGet/scheme", "value": "HTTP"}
38+
]'
39+
40+
# loki
41+
helm -n loki install loki-stack grafana/loki-stack \
42+
--values loki-values.yaml --create-namespace
43+
44+
# argocd
45+
myNamespaceArgoCD=argocd
46+
kubectl get namespace | grep -q "^$myNamespaceArgoCD " || kubectl create namespace $myNamespaceArgoCD
47+
kubectl -n $myNamespaceArgoCD apply -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
48+
kubectl -n argocd patch svc argocd-server -p '{"spec": {"type": "NodePort"}}'
49+
50+
# mlflow
51+
# take note to delete pvc when reinstalling
52+
# change default port 80 to different values for LoadBalancer
53+
helm -n mlflow upgrade --install sunrise bitnami/mlflow \
54+
--version 3.0.0 --create-namespace --set minio.persistence.size=50Gi --set tracking.service.ports.http=5080 --set tracking.service.ports.https=50443 --set minio.service.ports.api=5081 --set tracking.auth.enabled=false
55+
56+
ROOT_USER="username"
57+
ROOT_PASSWORD="yourpassword"
58+
export ENDPOINT="minio.minio:9000" BUCKET=thanos
59+
60+
## minio
61+
# https://github.com/minio/minio/blob/master/helm/minio/README.md
62+
helm -n minio install minio \
63+
--set replicas=2 \
64+
--set persistence.size=50Gi \
65+
--set rootUser=${ROOT_USER},rootPassword=${ROOT_PASSWORD} \
66+
--set persistence.enabled=true \
67+
minio-helm/minio --create-namespace
68+
69+
kubectl -n minio patch svc minio-console -p '{"spec": {"type": "LoadBalancer"}}'
70+
71+
kubectl run --namespace minio \
72+
minio-client --rm --tty -i --restart='Never' \
73+
--env MINIO_SERVER_ROOT_USER=${ROOT_USER} \
74+
--env MINIO_SERVER_ROOT_PASSWORD=${ROOT_PASSWORD} \
75+
--env MINIO_SERVER_HOST=minio.minio \
76+
--image docker.io/bitnami/minio-client -- mc mb -p minio/thanos
77+
78+
cat >objstore.yml <<EOF
79+
type: S3
80+
config:
81+
endpoint: "${ENDPOINT}"
82+
bucket: "${BUCKET}"
83+
access_key: "${ROOT_USER}"
84+
secret_key: "${ROOT_PASSWORD}"
85+
insecure: true
86+
EOF
87+
88+
kubectl create secret generic thanos-objstore \
89+
--from-file=objstore.yml -o yaml \
90+
--dry-run=client | kubectl -n prometheus apply -f -
91+
92+
helm -n prometheus upgrade --install prometheus-stack prometheus-community/kube-prometheus-stack \
93+
--set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false \
94+
--set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false \
95+
--set "prometheus.prometheusSpec.enableFeatures[0]=otlp-write-receiver" \
96+
--set alertmanager.ingress.enabled=true \
97+
--set prometheus.enabled=true \
98+
--values ./prometheus-with-thanos-values.yaml \
99+
--create-namespace
100+
101+
# install other thanos components
102+
helm -n prometheus upgrade --install thanos \
103+
bitnami/thanos --values ./thanos-values.yaml \
104+
--create-namespace
105+
106+
# install kserve
107+
# https://kserve.github.io/website/latest/admin/kubernetes_deployment/#2-install-network-controller
108+
arkade install cert-manager
109+
110+
#gateway
111+
kubectl -n kserve apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml
112+
113+
kubectl -n kserve apply -f - <<EOF
114+
apiVersion: gateway.networking.k8s.io/v1
115+
kind: GatewayClass
116+
metadata:
117+
name: envoy
118+
spec:
119+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
120+
EOF
121+
122+
kubectl -n kserve apply -f - <<EOF
123+
apiVersion: gateway.networking.k8s.io/v1
124+
kind: Gateway
125+
metadata:
126+
name: kserve-ingress-gateway
127+
namespace: kserve
128+
spec:
129+
gatewayClassName: envoy
130+
listeners:
131+
- name: http
132+
protocol: HTTP
133+
port: 80
134+
allowedRoutes:
135+
namespaces:
136+
from: All
137+
- name: https
138+
protocol: HTTPS
139+
port: 443
140+
tls:
141+
mode: Terminate
142+
certificateRefs:
143+
- kind: Secret
144+
name: my-secret
145+
namespace: kserve
146+
allowedRoutes:
147+
namespaces:
148+
from: All
149+
infrastructure:
150+
EOF
151+
152+
helm -n kserve install kserve-crd oci://ghcr.io/kserve/charts/kserve-crd --version v0.15.0
153+
154+
helm -n kserve install kserve oci://ghcr.io/kserve/charts/kserve --version v0.15.0 \
155+
--set kserve.controller.deploymentMode=RawDeployment \
156+
--set kserve.controller.gateway.ingressGateway.enableGatewayApi=true --set kserve.controller.gateway.ingressGateway.kserveGateway=kserve/kserve-ingress-gateway
157+
158+
# install coroot observability tool
159+
helm repo add coroot https://coroot.github.io/helm-charts
160+
helm repo update coroot
161+
162+
helm install -n coroot --create-namespace coroot-operator coroot/coroot-operator
163+
164+
helm install -n coroot coroot coroot/coroot-ce
165+
166+
kubectl port-forward -n coroot service/coroot-coroot 8080:8080
167+
168+
helm uninstall coroot -n coroot
169+
helm uninstall coroot-operator -n coroot
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# instructions
2+
# ============
3+
# - edit k0sctl.yaml to specify the IP addresses of kubernetes master and workers
4+
# - make sure you ssh-copy-id to root@eachmachines your public key to have passwordless root access
5+
6+
k0sctl apply --config k0sctl.yaml
7+
k0sctl kubeconfig --config ./k0sctl.yaml > $HOME/.kube/k0s.config
8+
export KUBECONFIG=$KUBECONFIG:$HOME/.kube/k0s.config
9+
[ -f $HOME/.bashrc ] && echo 'export KUBECONFIG=$KUBECONFIG:$HOME/.kube/k0s.config' >> $HOME/.bashrc
10+
[ -f $HOME/.zshrc ] && echo 'export KUBECONFIG=$KUBECONFIG:$HOME/.kube/k0s.config' >> $HOME/.zshrc
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ============
2+
# Insructions
3+
# ============
4+
# - change the IP addresses to your machines addresses
5+
# - make sure you can ssh as root to the machines without the need of password
6+
# by exporting your public key using ssh-copy-id to the remote machines
7+
# - more info: https://github.com/alexellis/k3sup
8+
#
9+
[ ! -f /usr/local/bin/k3sup ] && curl -sLS https://get.k3sup.dev | sh && sudo install ./k3sup* /usr/local/bin/k3sup
10+
11+
PRIMARYSERVER=x.x.x.x
12+
WORKERS=(y.y.y.y z.z.z.z a.a.a.a)
13+
14+
echo "Setting up primary server 1"
15+
k3sup install --host $PRIMARYSERVER \
16+
--user root \
17+
--cluster \
18+
--local-path kubeconfig \
19+
--context default
20+
21+
echo "Fetching the server's node-token into memory"
22+
export NODE_TOKEN=$(k3sup node-token --host $PRIMARYSERVER --user root)
23+
24+
for worker in $WORKERS; do
25+
echo "Setting up worker: $worker"
26+
k3sup join --host $worker --server-host $PRIMARYSERVER --node-token "$NODE_TOKEN" --user root &
27+
done
28+
29+
mkdir -p $HOME/.kube
30+
cp kubeconfig ~/.kube/k3s.config
31+
export KUBECONFIG=$KUBECONFIG:$HOME/.kube/k3s.config
32+
echo 'export KUBECONFIG=$KUBECONFIG:$HOME/.kube/k3s.config' >>$HOME/.zshrc
33+
echo 'export KUBECONFIG=$KUBECONFIG:$HOME/.kube/k3s.config' >>$HOME/.bashrc
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# export DOCKER_HOST=/var/run/docker.sock
2+
# kind-podman
3+
4+
podman machine init --cpus 4 --memory 12288
5+
podman machine set --rootful
6+
podman machine start
7+
8+
cat > kind-config.yaml <<EOF
9+
kind: Cluster
10+
apiVersion: kind.x-k8s.io/v1alpha4
11+
nodes:
12+
- role: control-plane
13+
- role: worker
14+
- role: worker
15+
EOF
16+
17+
kind create cluster --name kindk8s --config kind-config.yaml
18+
kubectl cluster-info --context kind-kindk8s
19+
kubectx kind-kindk8s
20+
kind get kubeconfig --name kindk8s > ~/.kube/kind.config
21+
22+
export KUBECONFIG=$KUBECONFIG:~/.kube/kind.config
23+
[ -f $HOME/.zhsrc ] && echo 'export KUBECONFIG=$KUBECONFIG:$HOME/.kube/kind.config' >> $HOME/.zshrc
24+
[ -f $HOME/.bashrc ] && echo 'export KUBECONFIG=$KUBECONFIG:$HOME/.kube/kind.config' >> $HOME/.bashrc
25+
26+
# podman container pause -a
27+
# podman container unpause -a
28+
29+
# podman machine stop
30+
# podman machine rm

argo-workflow/scripts/k0sctl.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: k0sctl.k0sproject.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: k0s-cluster
5+
spec:
6+
hosts:
7+
- ssh:
8+
address: x.y.z.a
9+
user: root
10+
port: 22
11+
keyPath: ~/.ssh/id_rsa
12+
role: controller
13+
- ssh:
14+
address: a.b.c.d
15+
user: root
16+
port: 22
17+
keyPath: ~/.ssh/id_rsa
18+
role: worker
19+
- ssh:
20+
address: r.s.t.x
21+
user: root
22+
port: 22
23+
keyPath: ~/.ssh/id_rsa
24+
role: worker
25+
k0s:
26+
version: null
27+
versionChannel: stable
28+
dynamicConfig: false
29+
config:
30+
apiVersion: k0s.k0sproject.io/v1beta1
31+
kind: Cluster
32+
metadata:
33+
name: k0s
34+
spec:
35+
api:
36+
k0sApiPort: 9443
37+
port: 6443
38+
installConfig:
39+
users:
40+
etcdUser: etcd
41+
kineUser: kube-apiserver
42+
konnectivityUser: konnectivity-server
43+
kubeAPIserverUser: kube-apiserver
44+
kubeSchedulerUser: kube-scheduler
45+
konnectivity:
46+
adminPort: 8133
47+
agentPort: 8132
48+
network:
49+
kubeProxy:
50+
disabled: false
51+
mode: iptables
52+
kuberouter:
53+
autoMTU: true
54+
mtu: 0
55+
peerRouterASNs: ""
56+
peerRouterIPs: ""
57+
podCIDR: 10.244.0.0/16
58+
provider: kuberouter
59+
serviceCIDR: 10.96.0.0/12
60+
podSecurityPolicy:
61+
defaultPolicy: 00-k0s-privileged
62+
storage:
63+
type: etcd
64+
telemetry:
65+
enabled: true

argo-workflow/scripts/objstore.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type: S3
2+
config:
3+
endpoint: "minio.minio:9000"
4+
bucket: "thanos"
5+
access_key: "changetominiologin"
6+
secret_key: "changetominiopassword"
7+
insecure: true

0 commit comments

Comments
 (0)