From 06e5819ae0388302fca4021d7c597d69db3bb2ee Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Wed, 25 Sep 2024 13:59:47 +0200 Subject: [PATCH] pixi run pre-commit run -a --- .editorconfig | 2 +- .gitlab-ci.yml | 6 +++--- .gitlab/agents/stage/config.yaml | 2 +- ansible/roles/k8s-common/tasks/k8s-repository.yml | 4 ++-- ansible/roles/k8s-common/tasks/main.yml | 12 ++++++------ .../files/cron/kill-after-timeout-pods.py | 6 ++---- .../files/cron/kill-succeeded-pods.py | 4 +--- .../files/usr/bin/orc2-fix-dind-bot.py | 7 +++---- ansible/roles/k8s-control-panel/tasks/main.yml | 6 +++--- ansible/roles/k8s-control-panel/tasks/metallb.yml | 8 ++++---- ansible/roles/k8s-worker/tasks/main.yml | 2 +- docs/source/deployment/gesis.md | 2 +- 12 files changed, 28 insertions(+), 33 deletions(-) diff --git a/.editorconfig b/.editorconfig index 216de0c51..5afdf958f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,4 +5,4 @@ charset = utf-8 end_of_line = lf indent_size = 2 indent_style = space -insert_final_newline = true \ No newline at end of file +insert_final_newline = true diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 052c71392..b2952d7e1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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/**/* @@ -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: @@ -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/ \ No newline at end of file + - curl https://notebooks-test.gesis.org/binder/ diff --git a/.gitlab/agents/stage/config.yaml b/.gitlab/agents/stage/config.yaml index 59f3bb059..c402b2fa8 100644 --- a/.gitlab/agents/stage/config.yaml +++ b/.gitlab/agents/stage/config.yaml @@ -1,3 +1,3 @@ ci_access: projects: - - id: methods-hub/interactive-environment \ No newline at end of file + - id: methods-hub/interactive-environment diff --git a/ansible/roles/k8s-common/tasks/k8s-repository.yml b/ansible/roles/k8s-common/tasks/k8s-repository.yml index 2fc66d81b..fc20cd955 100644 --- a/ansible/roles/k8s-common/tasks/k8s-repository.yml +++ b/ansible/roles/k8s-common/tasks/k8s-repository.yml @@ -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: @@ -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/ /" diff --git a/ansible/roles/k8s-common/tasks/main.yml b/ansible/roles/k8s-common/tasks/main.yml index e8aac97b6..20045b981 100644 --- a/ansible/roles/k8s-common/tasks/main.yml +++ b/ansible/roles/k8s-common/tasks/main.yml @@ -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 @@ -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: @@ -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: @@ -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: diff --git a/ansible/roles/k8s-control-panel/files/cron/kill-after-timeout-pods.py b/ansible/roles/k8s-control-panel/files/cron/kill-after-timeout-pods.py index e52f7d828..67fbca9ab 100644 --- a/ansible/roles/k8s-control-panel/files/cron/kill-after-timeout-pods.py +++ b/ansible/roles/k8s-control-panel/files/cron/kill-after-timeout-pods.py @@ -1,8 +1,8 @@ """Kill pods in Kubernetes cluster after timeout""" import argparse -import logging import datetime +import logging from kubernetes import client, config @@ -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(): diff --git a/ansible/roles/k8s-control-panel/files/cron/kill-succeeded-pods.py b/ansible/roles/k8s-control-panel/files/cron/kill-succeeded-pods.py index deb909c1d..3b75368e2 100644 --- a/ansible/roles/k8s-control-panel/files/cron/kill-succeeded-pods.py +++ b/ansible/roles/k8s-control-panel/files/cron/kill-succeeded-pods.py @@ -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(): diff --git a/ansible/roles/k8s-control-panel/files/usr/bin/orc2-fix-dind-bot.py b/ansible/roles/k8s-control-panel/files/usr/bin/orc2-fix-dind-bot.py index daf580ae7..f6e749b30 100644 --- a/ansible/roles/k8s-control-panel/files/usr/bin/orc2-fix-dind-bot.py +++ b/ansible/roles/k8s-control-panel/files/usr/bin/orc2-fix-dind-bot.py @@ -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" @@ -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!", diff --git a/ansible/roles/k8s-control-panel/tasks/main.yml b/ansible/roles/k8s-control-panel/tasks/main.yml index c0e156b8a..2143c6d49 100644 --- a/ansible/roles/k8s-control-panel/tasks/main.yml +++ b/ansible/roles/k8s-control-panel/tasks/main.yml @@ -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 @@ -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: diff --git a/ansible/roles/k8s-control-panel/tasks/metallb.yml b/ansible/roles/k8s-control-panel/tasks/metallb.yml index 894138f8e..9088a9f27 100644 --- a/ansible/roles/k8s-control-panel/tasks/metallb.yml +++ b/ansible/roles/k8s-control-panel/tasks/metallb.yml @@ -30,12 +30,12 @@ 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 @@ -43,8 +43,8 @@ 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 }}" diff --git a/ansible/roles/k8s-worker/tasks/main.yml b/ansible/roles/k8s-worker/tasks/main.yml index 7f1d6b455..4fb307a5e 100644 --- a/ansible/roles/k8s-worker/tasks/main.yml +++ b/ansible/roles/k8s-worker/tasks/main.yml @@ -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 diff --git a/docs/source/deployment/gesis.md b/docs/source/deployment/gesis.md index 548a42adb..039ccb9ea 100644 --- a/docs/source/deployment/gesis.md +++ b/docs/source/deployment/gesis.md @@ -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. \ No newline at end of file +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.