Skip to content

Commit

Permalink
Merge branch 'improve-docs' into 'gesis'
Browse files Browse the repository at this point in the history
pixi run pre-commit run -a

See merge request methods-hub/interactive-environment!20
  • Loading branch information
rgaiacs committed Sep 25, 2024
2 parents 41b46ed + 06e5819 commit d22e360
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
insert_final_newline = true
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variables:
- if: $CI_SERVER_HOST == 'git.gesis.org' && $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- .gitlab.yml
when: manual
when: manual
- if: $CI_SERVER_HOST == 'git.gesis.org' && $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- ansible/**/*
Expand Down Expand Up @@ -49,7 +49,7 @@ include:
ssh-key-type: ed25519

.gesis helm deploy:
image:
image:
name: docker-private.gesis.intra/gesis/ilcm/orc2/k8s:latest
entrypoint: [""]
variables:
Expand Down Expand Up @@ -125,4 +125,4 @@ smoke test after stage deploy:
- !reference [.geis-merge-request, rules]
- !reference [.geis-push-main, rules]
script:
- curl https://notebooks-test.gesis.org/binder/
- curl https://notebooks-test.gesis.org/binder/
2 changes: 1 addition & 1 deletion .gitlab/agents/stage/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ci_access:
projects:
- id: methods-hub/interactive-environment
- id: methods-hub/interactive-environment
4 changes: 2 additions & 2 deletions ansible/roles/k8s-common/tasks/k8s-repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ansible.builtin.get_url:
url: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_common_kubernetes_version }}/deb/Release.key"
dest: /tmp/kubernetes-archive-keyring.asc
mode: '0644'
mode: "0644"
force: true
- name: Convert the public GPG key to binary
ansible.builtin.command:
Expand All @@ -43,7 +43,7 @@
src: /tmp/kubernetes.gpg
dest: /etc/apt/keyrings/kubernetes.gpg
remote_src: true
mode: '0644'
mode: "0644"
- name: Add Kubernetes repository
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes.gpg] https://pkgs.k8s.io/core:/stable:/v{{ k8s_common_kubernetes_version }}/deb/ /"
Expand Down
12 changes: 6 additions & 6 deletions ansible/roles/k8s-common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- name: Ensure DOCKER_CLIENT_TIMEOUT is set
ansible.builtin.lineinfile:
path: /etc/environment
regexp: '^DOCKER_CLIENT_TIMEOUT='
regexp: "^DOCKER_CLIENT_TIMEOUT="
line: DOCKER_CLIENT_TIMEOUT=180
- name: Disable SWAP since kubernetes can't work with swap enabled
ansible.builtin.command: swapoff -a
Expand All @@ -27,17 +27,17 @@
- name: Allow IP forward
ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '1'
value: "1"
state: present
- name: Set inotify max user instances
ansible.posix.sysctl:
name: fs.inotify.max_user_instances
value: '1280'
value: "1280"
state: present
- name: Set inotify max user watches
ansible.posix.sysctl:
name: fs.inotify.max_user_watches
value: '655360'
value: "655360"
state: present
- name: Create directory for Persistent Volume
ansible.builtin.import_tasks:
Expand All @@ -46,7 +46,7 @@
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/trusted.gpg.d/docker.asc
mode: '0644'
mode: "0644"
force: true
- name: Add Docker repository
ansible.builtin.apt_repository:
Expand All @@ -57,7 +57,7 @@
ansible.builtin.get_url:
url: https://baltocdn.com/helm/signing.asc
dest: /etc/apt/trusted.gpg.d/helm.asc
mode: '0644'
mode: "0644"
force: true
- name: Add Helm repository
ansible.builtin.apt_repository:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Kill pods in Kubernetes cluster after timeout"""

import argparse
import logging
import datetime
import logging

from kubernetes import client, config

Expand Down Expand Up @@ -48,9 +48,7 @@ def kill_pod(pod):
api_response = v1.delete_namespaced_pod(pod.metadata.name, NAMESPACE)
logger.info("Pod %s deleted.", api_response.metadata.name)
except client.exceptions.ApiException as exception:
logger.info(
"Fail to delete pod %s due %s", pod.metadata.name, exception
)
logger.info("Fail to delete pod %s due %s", pod.metadata.name, exception)


def kill_timed_out_pods():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def kill_pod(pod):
api_response = v1.delete_namespaced_pod(pod.metadata.name, NAMESPACE)
logger.info("Pod %s deleted.", api_response.metadata.name)
except client.exceptions.ApiException as exception:
logger.info(
"Fail to delete pod %s due %s", pod.metadata.name, exception
)
logger.info("Fail to delete pod %s due %s", pod.metadata.name, exception)


def kill_succeeded_pods():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import logging
import os

from kubernetes import client, config, watch

from invoke import Responder
from fabric import Connection
from invoke import Responder
from kubernetes import client, config, watch

logging.basicConfig(
format="%(asctime)s %(levelname)-8s | %(message)s", datefmt="%Y-%m-%d %H:%M:%S"
Expand Down Expand Up @@ -99,7 +98,7 @@ def monitor_cluster():
logger.info(
"Fail to delete pod %s due %s", pod_name, exception
)

elif event["object"].type == "Normal":
logger.debug(
"Found Normal event in %s ... skipping!",
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/k8s-control-panel/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
- name: Copy join command to local file
ansible.builtin.fetch:
src: /tmp/kubernetes_join_command
dest: '{{ ANSIBLE_CONTROL_NODE_TMP }}'
dest: "{{ ANSIBLE_CONTROL_NODE_TMP }}"
- name: Add Container Network Interface (CNI) to Kubernetes cluster
ansible.builtin.import_tasks:
file: cni.yml
Expand All @@ -83,13 +83,13 @@
repo_url: https://charts.gitlab.io
- name: Deploy GitLab agent
kubernetes.core.helm:
name: 'gitlab-agent-{{ inventory_file | basename }}'
name: "gitlab-agent-{{ inventory_file | basename }}"
chart_ref: gitlab/gitlab-agent
release_namespace: gitlab-agent
dependency_update: true
create_namespace: true
set_values:
- value: 'config.token={{ GITLAB_K8S_TOKEN }}'
- value: "config.token={{ GITLAB_K8S_TOKEN }}"
- value: config.kasAddress=wss://git.gesis.org/-/kubernetes-agent/
- name: Copy orc2-fix-jupyterhub-bot Python script
ansible.builtin.copy:
Expand Down
8 changes: 4 additions & 4 deletions ansible/roles/k8s-control-panel/tasks/metallb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: '{{ k8s_control_panel_metallb_ip_address_pool_name }}'
name: "{{ k8s_control_panel_metallb_ip_address_pool_name }}"
namespace: metallb
spec:
addresses:
# TODO Use Jinja filter to automate this.
- '{{ K8S_INGRESS }}-{{ K8S_INGRESS }}'
- "{{ K8S_INGRESS }}-{{ K8S_INGRESS }}"
- name: Configure L2 Advertisement for MetalLB
kubernetes.core.k8s:
state: present
definition:
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: '{{ k8s_control_panel_metallb_ip_address_pool_name }}-l2-advertisement'
name: "{{ k8s_control_panel_metallb_ip_address_pool_name }}-l2-advertisement"
namespace: metallb
spec:
ipAddressPools:
- '{{ k8s_control_panel_metallb_ip_address_pool_name }}'
- "{{ k8s_control_panel_metallb_ip_address_pool_name }}"
2 changes: 1 addition & 1 deletion ansible/roles/k8s-worker/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: Copy join command
ansible.builtin.copy:
src: '{{ ANSIBLE_CONTROL_NODE_TMP }}/{{ K8S_CONTROL_PLANE_ALIAS }}/tmp/kubernetes_join_command'
src: "{{ ANSIBLE_CONTROL_NODE_TMP }}/{{ K8S_CONTROL_PLANE_ALIAS }}/tmp/kubernetes_join_command"
dest: /tmp/kubernetes_join_command
mode: u=rwx,g=rx,o=rx
- name: Attempt to join cluster
Expand Down
2 changes: 1 addition & 1 deletion docs/source/deployment/gesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Cloud environments provide a load balancer to the Kubernetes clusters. Unfortuna

## Virtual Private Server configuration with Ansible

We use [Ansible](https://www.ansible.com/) to automate the configuration of the virtual private server (VPS) provided by GESIS. After a successful configuration, we will have a operational Kubernetes cluster to deploy mybinder.org.
We use [Ansible](https://www.ansible.com/) to automate the configuration of the virtual private server (VPS) provided by GESIS. After a successful configuration, we will have a operational Kubernetes cluster to deploy mybinder.org.

0 comments on commit d22e360

Please sign in to comment.