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

Issue 39 | Enhancement: rename all the entries from middleware to manager #50

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Constants
# =========

version=0.0.1
version=0.0.2
repository=qiskit

notebookImageName=$(repository)/quantum-serverless-notebook
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
3. [Quickstart Guide](docs/quickstart_guide.md)
4. Modules:
1. [Client](./client)
2. [Middleware](./manager)
2. [Manager](./manager)
3. [Infrastructure](./infrastructure)
5. [Tutorials](docs/tutorials/)
6. [Guides](docs/guides/)
Expand Down
2 changes: 1 addition & 1 deletion client/quantum_serverless/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.0.2
4 changes: 2 additions & 2 deletions client/quantum_serverless/quantum_serverless.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,11 @@ def load_config(config: Optional[Dict[str, Any]] = None) -> List[Provider]:
def get_auto_discovered_provider(
manager_address: str, token: Optional[str] = None
) -> Optional[Provider]:
"""Makes http request to middleware to get available clusters."""
"""Makes http request to manager to get available clusters."""
clusters = []

headers = {"Authorization": f"Bearer {token}"} if token else None
url = f"{manager_address}/quantum-serverless-middleware/cluster/"
url = f"{manager_address}/quantum-serverless-manager/cluster/"

try:
response = requests.get(url, headers=headers, timeout=10)
Expand Down
4 changes: 2 additions & 2 deletions client/tests/test_quantum_serverless.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ def test_available_clusters_with_mock(self):
with requests_mock.Mocker() as mocker:
clusters_mocks = [{"name": f"mock-cluster-{i}"} for i in range(4)]
mocker.get(
"http://mock_host:42/quantum-serverless-middleware/cluster/",
"http://mock_host:42/quantum-serverless-manager/cluster/",
text=json.dumps(clusters_mocks),
)
for mock_cluster in clusters_mocks:
name = mock_cluster.get("name")
mocker.get(
f"http://mock_host:42/quantum-serverless-middleware/cluster/{name}",
f"http://mock_host:42/quantum-serverless-manager/cluster/{name}",
text=json.dumps(
{
"name": name,
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/helm/quantumserverless/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ dependencies:
condition: rayOperatorEnable
- name: ray-cluster
condition: rayClusterEnable
- name: middleware
condition: middlewareEnable
- name: manager
condition: managerEnable
16 changes: 8 additions & 8 deletions infrastructure/helm/quantumserverless/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Helm configuration

Main configuration to setup your k8s cluster and the services that this project uses. The helm configuration contains 4 charts: jupyter, middleware, operator and ray-cluster.
Main configuration to setup your k8s cluster and the services that this project uses. The helm configuration contains 4 charts: jupyter, manager, operator and ray-cluster.

## Installation

Expand All @@ -27,16 +27,16 @@ Install from specific values file
| jupyter.service.port | Port number that service will be exposed externally. |
| jupyter.ingress.enabled | Specifies if you are going to use ingress to expose the service. |

**Middleware**
**Manager**

| Name | Description |
|-------------------------------|-------------------------------------------------------------------|
| middlewareEnable | Specify if helm will execute the middleware configuration. |
| middleware.image | Docker image configuration to deploy the manager. |
| middleware.imagePullSecrets | Secrets to pull the image from a private registry. |
| middleware.container.port | Port number that the pod will use in the cluster. |
| middleware.service.port | Port number that service will be exposed externally. |
| middleware.ingress.enabled | Specifies if you are going to use ingress to expose the service. |
| managerEnable | Specify if helm will execute the manager configuration. |
| manager.image | Docker image configuration to deploy the manager. |
| manager.imagePullSecrets | Secrets to pull the image from a private registry. |
| manager.container.port | Port number that the pod will use in the cluster. |
| manager.service.port | Port number that service will be exposed externally. |
| manager.ingress.enabled | Specifies if you are going to use ingress to expose the service. |

**Ray cluster**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- name: JUPYTER_TOKEN
value: {{ .Values.jupyterToken | quote }}
- name: QS_CLUSTER_MANAGER_ADDRESS
value: "http://{{ .Release.Name }}-middleware:{{ .Values.middlewarePort }}"
value: "http://{{ .Release.Name }}-manager:{{ .Values.managerPort }}"
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Declare variables to be passed into your templates.

jupyterToken: "123"
middlewareHost: ""
middlewarePort: 5000
managerHost: ""
managerPort: 5000

replicaCount: 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: middleware
description: Helm chart to deploy the middleware python application in kubernetes
name: manager
description: Helm chart to deploy the manager python application in kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "middleware.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "manager.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "middleware.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "middleware.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "manager.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "manager.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "middleware.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "manager.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "middleware.name" -}}
{{- define "manager.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -10,7 +10,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "middleware.fullname" -}}
{{- define "manager.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "middleware.chart" -}}
{{- define "manager.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "middleware.labels" -}}
helm.sh/chart: {{ include "middleware.chart" . }}
{{ include "middleware.selectorLabels" . }}
{{- define "manager.labels" -}}
helm.sh/chart: {{ include "manager.chart" . }}
{{ include "manager.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "middleware.selectorLabels" -}}
app.kubernetes.io/name: {{ include "middleware.name" . }}
{{- define "manager.selectorLabels" -}}
app.kubernetes.io/name: {{ include "manager.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "middleware.serviceAccountName" -}}
{{- define "manager.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "middleware.fullname" .) .Values.serviceAccount.name }}
{{- default (include "manager.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "middleware.fullname" . }}-crb
name: {{ include "manager.fullname" . }}-crb
namespace: {{ .Release.Namespace }}
subjects:
- kind: User
name: system:serviceaccount:ray:{{ include "middleware.fullname" . }}
name: system:serviceaccount:ray:{{ include "manager.fullname" . }}
roleRef:
kind: ClusterRole
name: {{ include "middleware.fullname" . }}-cr
name: {{ include "manager.fullname" . }}-cr
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "middleware.fullname" . }}-cr
name: {{ include "manager.fullname" . }}-cr
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: ["apiextensions.k8s.io"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "middleware.fullname" . }}
name: {{ include "manager.fullname" . }}
labels:
{{- include "middleware.labels" . | nindent 4 }}
{{- include "manager.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "middleware.selectorLabels" . | nindent 6 }}
{{- include "manager.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "middleware.selectorLabels" . | nindent 8 }}
{{- include "manager.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "middleware.serviceAccountName" . }}
serviceAccountName: {{ include "manager.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "middleware.fullname" . }}
name: {{ include "manager.fullname" . }}
labels:
{{- include "middleware.labels" . | nindent 4 }}
{{- include "manager.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "middleware.fullname" . }}
name: {{ include "manager.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "middleware.fullname" . -}}
{{- $fullName := include "manager.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
Expand All @@ -17,7 +17,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "middleware.labels" . | nindent 4 }}
{{- include "manager.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "middleware.fullname" . }}-rb
name: {{ include "manager.fullname" . }}-rb
namespace: {{ .Release.Namespace }}
subjects:
- kind: User
name: system:serviceaccount:{{ .Release.Namespace }}:{{ include "middleware.fullname" . }}
name: system:serviceaccount:{{ .Release.Namespace }}:{{ include "manager.fullname" . }}
roleRef:
kind: Role
name: {{ include "middleware.fullname" . }}-role
name: {{ include "manager.fullname" . }}-role
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "middleware.fullname" . }}-role
name: {{ include "manager.fullname" . }}-role
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: ["ray.io", "cluster.ray.io"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "middleware.fullname" . }}
name: {{ include "manager.fullname" . }}
labels:
{{- include "middleware.labels" . | nindent 4 }}
{{- include "manager.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -12,4 +12,4 @@ spec:
port: {{ .Values.service.port }}
name: http
selector:
{{- include "middleware.selectorLabels" . | nindent 4 }}
{{- include "manager.selectorLabels" . | nindent 4 }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "middleware.serviceAccountName" . }}
name: {{ include "manager.serviceAccountName" . }}
labels:
{{- include "middleware.labels" . | nindent 4 }}
{{- include "manager.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
Tansito marked this conversation as resolved.
Show resolved Hide resolved
kind: Pod
metadata:
name: "{{ include "manager.fullname" . }}-test-connection"
labels:
{{- include "manager.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "manager.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Default values for middleware.
# Default values for manager.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

Expand Down

This file was deleted.

Loading