Created
July 14, 2025 20:17
-
-
Save leshikus/2c6dacb4a4d64bf362dc605b515e24cd to your computer and use it in GitHub Desktop.
setup jupyterhub via kind
This file contains hidden or 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
--- | |
- name: Setup local Kubernetes cluster with JupyterHub | |
hosts: localhost | |
become: true | |
vars: | |
arch: amd64 | |
cluster_name: k8s-test | |
kubectl_url: "https://dl.k8s.io/release/{{ lookup('url', 'https://dl.k8s.io/release/stable.txt') }}/bin/linux/{{ arch }}/kubectl" | |
kind_url: "https://kind.sigs.k8s.io/dl/latest/kind-linux-{{ arch }}" | |
helm_script_url: "https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3" | |
tasks: | |
- name: Ensure curl is installed | |
package: | |
name: curl | |
state: present | |
- name: Download and install kubectl | |
get_url: | |
url: "{{ kubectl_url }}" | |
dest: /tmp/kubectl | |
mode: '0755' | |
register: kubectl_download | |
- name: Move kubectl to /usr/local/bin | |
copy: | |
src: /tmp/kubectl | |
dest: /usr/local/bin/kubectl | |
remote_src: yes | |
mode: '0755' | |
when: kubectl_download.changed | |
- name: Download and install kind | |
get_url: | |
url: "{{ kind_url }}" | |
dest: /tmp/kind | |
mode: '0755' | |
register: kind_download | |
- name: Move kind to /usr/local/bin | |
copy: | |
src: /tmp/kind | |
dest: /usr/local/bin/kind | |
remote_src: yes | |
mode: '0755' | |
when: kind_download.changed | |
- name: Install Helm if not present | |
shell: | | |
curl -fsSL -o get_helm.sh {{ helm_script_url }} | |
chmod u+x get_helm.sh | |
./get_helm.sh | |
args: | |
creates: /usr/local/bin/helm | |
- name: Write kind cluster config | |
copy: | |
dest: ./kind-config.yaml | |
content: | | |
kind: Cluster | |
apiVersion: kind.x-k8s.io/v1alpha4 | |
nodes: | |
- role: control-plane | |
- role: worker | |
- role: worker | |
- name: Create kind cluster | |
shell: kind create cluster --name {{ cluster_name }} --config kind-config.yaml | |
args: | |
creates: ~/.kube/config | |
- name: Wait for nodes to be ready | |
shell: kubectl get nodes | |
register: nodes_out | |
retries: 10 | |
delay: 5 | |
until: '"Ready" in nodes_out.stdout' | |
- name: Add JupyterHub Helm repo | |
shell: helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ | |
args: | |
creates: ~/.cache/helm/repository/jupyterhub-index.yaml | |
- name: Update Helm repos | |
shell: helm repo update | |
- name: Save default JupyterHub values.yaml | |
shell: helm show values jupyterhub/jupyterhub > values.yaml | |
args: | |
creates: values.yaml | |
- name: Deploy JupyterHub | |
shell: > | |
helm upgrade --cleanup-on-fail --install my-jupyter | |
jupyterhub/jupyterhub | |
--namespace jhub | |
--create-namespace | |
--values values.yaml | |
- name: Wait for JupyterHub pods | |
shell: kubectl get pods -n jhub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment