Skip to content

Commit

Permalink
Add workflow to test byzer-helm
Browse files Browse the repository at this point in the history
  • Loading branch information
chncaesar committed Mar 19, 2023
1 parent e5125e0 commit e45a121
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 48 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Lint and Test Charts

on: [pull_request]

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up kubectl
uses: azure/setup-kubectl@v3

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0

- name: Install bitnami repo
run: helm repo add bitnami https://charts.bitnami.com/bitnami

- uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (lint)
run: ct lint --target-branch ${{ github.event.repository.default_branch }}

- name: start minikube
uses: medyagh/setup-minikube@latest
id: minikube
with:
cache: true
minikube-version: 1.22.0

- name: Copy and edit values.yaml
run: python -m pip install ruamel.yaml kubernetes && cd byzer-lang && python ./cp_write_values_yaml.py

- name: Run byzer-lang-testing (install)
run: ct install --debug --chart-dirs ./byzer-lang --charts byzer-lang --helm-extra-args '--timeout 480s'
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea/**
/byzer-lang/values.yaml
/byzer-notebook/values.yaml
/package.sh
/charts
/charts
byzer-lang/values.yaml
13 changes: 0 additions & 13 deletions byzer-lang/byzer-lang-headless-service.sh

This file was deleted.

54 changes: 54 additions & 0 deletions byzer-lang/cp_write_values_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import ruamel.yaml
from kubernetes import client, config
import socket
from urllib.parse import urlparse


def get_cluster_url() -> str:
config.load_kube_config()
v1 = client.CoreV1Api()
api_server = v1.api_client.configuration.host
parse_result = urlparse(api_server)
if parse_result.hostname == "127.0.0.1":
host = socket.gethostbyname(socket.gethostname())
api_server = parse_result.scheme + "://" + host + ":" + str(parse_result.port)
print(api_server)
return api_server


def rewrite_conf(conf: dict) -> dict:

conf['clusterUrl'] = get_cluster_url()

spark_conf = conf['spark']
spark_conf['driver.memory'] = "1024m"
spark_conf['driver.cores'] = "1"
spark_conf['executor.memory'] = "512m"
spark_conf['kubernetes.driver.limit.cores'] = "400m"
spark_conf['kubernetes.driver.request.cores'] = "400m"
spark_conf['kubernetes.executor.limit.cores'] = "200m"
spark_conf['kubernetes.executor.request.cores'] = "200m"

byzer_conf = conf['byzer']
byzer_conf['mainJar'] = "byzer-lang-3.3.0-2.12-2.3.5.jar"

image_conf = conf['image']
image_conf["repository"] = "byzer/byzer-lang-k8s-full"
image_conf["tag"] = "3.3.0-2.3.5-2023-03-09"

conf['fs']['cloud']['storage']['enabled'] = False
conf['readinessProbe']['initialDelaySeconds'] = 120
conf['minReadySeconds'] = 120
conf['livenessProbe']['initialDelaySeconds'] = 120

return conf


yaml = ruamel.yaml.YAML()
yaml.preserve_quotes = True
with open('values.example.yaml') as fp:
data = yaml.load(fp)
rewrite_conf(data)

with open('values.yaml', 'w') as outfile:
yaml.dump(data, outfile)
31 changes: 0 additions & 31 deletions byzer-lang/index.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions byzer-lang/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,22 @@ spec:
targetPort: http
protocol: TCP
name: http
selector:
{{- include "byzer-lang.selectorLabels" . | nindent 4 }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "byzer-lang.fullname" . }}-headless-service
labels:
{{- include "byzer-lang.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
clusterIP: None
selector:
{{- include "byzer-lang.selectorLabels" . | nindent 4 }}
4 changes: 2 additions & 2 deletions byzer-lang/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Pod
metadata:
name: {{ include "byzer-lang.fullname" . }}-test-connection"
name: {{ include "byzer-lang.fullname" . }}-test-connection
labels:
{{- include "byzer-lang.labels" . | nindent 4 }}
annotations:
Expand All @@ -11,5 +11,5 @@ spec:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "byzer-lang.fullname" . }}:{{ .Values.service.port }}']
args: ['{{ include "byzer-lang.fullname" . }}-service:{{ .Values.service.port }}']
restartPolicy: Never

0 comments on commit e45a121

Please sign in to comment.