Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kind: calico-friendly cluster configuration #675

Merged
merged 3 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions etc/kind-localhost-30443-disable-default-cni.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
networking:
disableDefaultCNI: true
podSubnet: 192.168.0.0/16
nodes:
- extraPortMappings:
- containerPort: 30443
hostPort: 30443
protocol: TCP
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
role: control-plane
2 changes: 1 addition & 1 deletion helm/reana/templates/reana-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "reana.prefix" . }}-cache
namespace: {{ .Release.Namespace }}
spec:
type: NodePort
type: ClusterIP
selector:
app: {{ include "reana.prefix" . }}-cache
ports:
Expand Down
2 changes: 1 addition & 1 deletion helm/reana/templates/reana-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ include "reana.prefix" . }}-db
namespace: {{ .Release.Namespace }}
spec:
type: NodePort
type: ClusterIP
selector:
app: {{ include "reana.prefix" . }}-db
ports:
Expand Down
3 changes: 1 addition & 2 deletions helm/reana/templates/reana-message-broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "reana.prefix" . }}-message-broker
namespace: {{ .Release.Namespace }}
spec:
type: "NodePort"
type: "ClusterIP"
ports:
- port: 5672
targetPort: 5672
Expand All @@ -14,7 +14,6 @@ spec:
{{- if .Values.debug.enabled }}
- port: 31672
targetPort: 15672
nodePort: 31672
name: "management"
protocol: TCP
{{- else }}
Expand Down
2 changes: 1 addition & 1 deletion helm/reana/templates/reana-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "reana.prefix" . }}-server
namespace: {{ .Release.Namespace }}
spec:
type: "NodePort"
type: "ClusterIP"
ports:
- port: 80
targetPort: 5000
Expand Down
2 changes: 1 addition & 1 deletion helm/reana/templates/reana-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ include "reana.prefix" . }}-ui
namespace: {{ .Release.Namespace }}
spec:
type: "NodePort"
type: "ClusterIP"
ports:
- port: 80
targetPort: 80
Expand Down
19 changes: 18 additions & 1 deletion helm/reana/templates/reana-workflow-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "reana.prefix" . }}-workflow-controller
namespace: {{ .Release.Namespace }}
spec:
type: "NodePort"
type: "ClusterIP"
ports:
- port: 80
targetPort: 5000
Expand All @@ -14,6 +14,23 @@ spec:
selector:
app: {{ include "reana.prefix" . }}-workflow-controller
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "reana.prefix" . }}-workflow-controller
namespace: {{ .Release.Namespace }}
spec:
podSelector:
matchLabels:
app: {{ include "reana.prefix" . }}-workflow-controller
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
app: {{ include "reana.prefix" . }}-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
15 changes: 13 additions & 2 deletions reana/reana_dev/cluster.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2020, 2021 CERN.
# Copyright (C) 2020, 2021, 2022 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -66,8 +66,13 @@ def cluster_commands():
help="In which mode to run REANA cluster? (releasehelm,releasepypi,latest,debug) [default=latest]",
)
@click.option("--worker-nodes", default=0, help="How many worker nodes? [default=0]")
@click.option(
"--disable-default-cni",
is_flag=True,
help="Disable default CNI and use e.g. Calico.",
)
@cluster_commands.command(name="cluster-create")
def cluster_create(mounts, mode, worker_nodes): # noqa: D301
def cluster_create(mounts, mode, worker_nodes, disable_default_cni): # noqa: D301
"""Create new REANA cluster.

\b
Expand Down Expand Up @@ -146,6 +151,12 @@ def add_volume_mounts(node):
"nodes": nodes,
}

if disable_default_cni:
cluster_config["networking"] = {
"disableDefaultCNI": True,
"podSubnet": "192.168.0.0/16",
}

cluster_create = "cat <<EOF | kind create cluster --config=-\n{cluster_config}\nEOF"
cluster_create = cluster_create.format(cluster_config=yaml.dump(cluster_config))

Expand Down
8 changes: 8 additions & 0 deletions reana/reana_dev/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def run_commands():
",".join(WORKFLOW_ENGINE_LIST_ALL)
),
)
@click.option(
"--disable-default-cni",
is_flag=True,
help="Disable default CNI and use e.g. Calico.",
)
@run_commands.command(name="run-ci")
def run_ci(
build_arg,
Expand All @@ -273,6 +278,7 @@ def run_ci(
admin_email,
admin_password,
workflow_engine,
disable_default_cni,
): # noqa: D301
"""Run CI build.

Expand Down Expand Up @@ -307,6 +313,8 @@ def run_ci(
cmd = "reana-dev cluster-create --mode {}".format(mode)
for mount in mounts:
cmd += " -m {}".format(mount)
if disable_default_cni:
cmd += " --disable-default-cni"
run_command(cmd, "reana")
# prefetch and load images for selected demo examples
if mode in ("releasepypi", "latest", "debug"):
Expand Down