Skip to content

Commit

Permalink
Initial setup mash 2
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Mar 8, 2023
1 parent 87cc205 commit b2786b9
Show file tree
Hide file tree
Showing 19 changed files with 242 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
python-version: "3.11"

- name: Install dependencies
run: pip install chartpress yamllint
run: pip install -r dev-requirements.txt

- name: Lint and validate
run: tools/templates/lint-and-validate.py
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ repos:
rev: v3.0.0-alpha.6
hooks:
- id: prettier
exclude: binderhub-service/templates/.*

# Linting: Python code (see the file .flake8)
- repo: https://github.com/PyCQA/flake8
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# binderhub-service
# binderhub-service
48 changes: 48 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# How to make a release

`binderhub-service` is a Helm chart available in the Helm chart repository
`https://2i2c.org/binderhub-service`.

## Pre-requisites

- Push rights to [2i2c-org/binderhub-service]

## Steps to make a release

1. Create a PR updating `docs/source/changelog.md` with [github-activity] and
continue only when its merged.

```shell
pip install github-activity

github-activity --heading-level=3 2i2c-org/binderhub-service
```

1. Checkout main and make sure it is up to date.

```shell
git checkout main
git fetch origin main
git reset --hard origin/main
```

1. Update the version, make commits, and push a git tag with `tbump`.

```shell
pip install tbump
tbump --dry-run ${VERSION}

tbump ${VERSION}
```

Following this, the [CI system] will build and publish a release.

1. Reset the version back to dev, e.g. `1.1.0-0.dev` after releasing `1.0.0`

```shell
tbump --no-tag ${NEXT_VERSION}-0.dev
```

[2i2c-org/binderhub-service]: https://github.com/2i2c-org/binderhub-service
[github-activity]: https://github.com/executablebooks/github-activity
[ci system]: https://github.com/2i2c-org/binderhub-service/actions/workflows/release.yaml
10 changes: 10 additions & 0 deletions binderhub-service/.helmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Anything within the root folder of the Helm chart, where Chart.yaml resides,
# will be embedded into the packaged Helm chart. This is reasonable since only
# when the templates render after the chart has been packaged and distributed,
# will the templates logic evaluate that determines if other files were
# referenced, such as our our files/hub/jupyterhub_config.py.
#
# Here are files that we intentionally ignore to avoid them being packaged,
# because we don't want to reference them from our templates anyhow.
values.schema.yaml

# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
Expand Down
34 changes: 12 additions & 22 deletions binderhub-service/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
# Chart.yaml v2 reference: https://helm.sh/docs/topics/charts/#the-chartyaml-file
apiVersion: v2
name: binderhub-service
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
version: 0.0.1-set.by.chartpress
appVersion: "1.0.0"
description: A BinderHub installation separate from JupyterHub
keywords: [binderhub, binderhub-service, repo2docker, jupyterhub, jupyter]
home: https://2i2c.org/binderhub-service
sources: [https://github.com/2i2c-org/binderhub-service]
icon: https://binderhub.readthedocs.io/en/latest/_static/logo.png
kubeVersion: ">=1.23.0-0"
maintainers:
- name: Erik Sundell
email: [email protected]
6 changes: 2 additions & 4 deletions binderhub-service/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "binderhub-service.fullname" . }}
labels:
{{- include "binderhub-service.labels" . | nindent 4 }}
labels: {{- include "binderhub-service.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "binderhub-service.selectorLabels" . | nindent 4 }}
selector: {{- include "binderhub-service.selectorLabels" . | nindent 4 }}
26 changes: 26 additions & 0 deletions binderhub-service/values.schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This schema (a JSONSchema in YAML format) is used to generate
# values.schema.json to be packaged with the Helm chart.
#
# This schema is also planned to be used by our documentation system to build
# the configuration reference section based on the description fields. See
# docs/source/conf.py for that logic in the future!
#
# We look to document everything we have default values for in values.yaml, but
# we don't look to enforce the perfect validation logic within this file.
#
# ref: https://helm.sh/docs/topics/charts/#schema-files
# ref: https://json-schema.org/learn/getting-started-step-by-step.html
#
$schema: http://json-schema.org/draft-07/schema#
type: object
additionalProperties: true
required:
- global
properties:
nameOverride:
type: string
fullnameOverride:
type: string
global:
type: object
additionalProperties: true
92 changes: 35 additions & 57 deletions binderhub-service/values.yaml
Original file line number Diff line number Diff line change
@@ -1,82 +1,60 @@
# Default values for binderhub-service.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
# General configuration
# -----------------------------------------------------------------------------
#
nameOverride: ""
fullnameOverride: ""
global: {}

# Deployment resource
# -----------------------------------------------------------------------------
#
replicaCount: 1

image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
repository: quay.io/2i2c/binderhub-service
tag: "set-by-chartpress"
pullPolicy: ""
pullSecrets: []
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
resources: {}

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
podAnnotations: {}
podSecurityContext: {}
nodeSelector: {}
tolerations: []
affinity: {}

# ServiceAccount resource
# -----------------------------------------------------------------------------
#
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

# Service resource
# -----------------------------------------------------------------------------
#
service:
type: ClusterIP
port: 80

# Ingress resource
# -----------------------------------------------------------------------------
#
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

affinity: {}
2 changes: 1 addition & 1 deletion chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ charts:
# binderhub-service, the container where the binderhub the Python
# application is running.
binderhub-service:
valuesPath: binderhub.image
valuesPath: image
8 changes: 5 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#
chartpress

# pytest run tests that require requests and pyyaml
# pytest is used to run tests
pytest

# pyyaml is used by script under tools/
pyyaml

# tbump is making releases
tbump
# yamllint is used by tools/templates/lint-and-validate.py script
yamllint
2 changes: 1 addition & 1 deletion images/binderhub-service/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Use the "Run workflow" button at https://github.com/2i2c-org/binderhub-service/actions/workflows/watch-dependencies.yaml
#
alembic==1.10.0
alembic==1.10.1
# via jupyterhub
async-generator==1.10
# via jupyterhub
Expand Down
83 changes: 83 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# NOTE: This github repository houses a Helm chart and some Python based scripts
# - not a python package. This file is only used to provide configuration
# for misc Python based utilities.
#

# autoflake is used for autoformatting Python code
#
# ref: https://github.com/PyCQA/autoflake#readme
#
[tool.autoflake]
ignore-init-module-imports = true
remove-all-unused-imports = true
remove-duplicate-keys = true
remove-unused-variables = true


# isort is used for autoformatting Python code
#
# ref: https://pycqa.github.io/isort/
#
[tool.isort]
profile = "black"


# black is used for autoformatting Python code
#
# ref: https://black.readthedocs.io/en/stable/
#
[tool.black]
target_version = [
"py310",
"py311",
]


# pytest is used for running Python based tests
#
# ref: https://docs.pytest.org/en/stable/
#
[tool.pytest.ini_options]
addopts = "--verbose --color=yes --durations=10"
asyncio_mode = "auto"


# tbump is a tool to update version fields that we use
# to update baseVersion in chartpress.yaml as documented
# in RELEASE.md
#
# Config reference: https://github.com/your-tools/tbump#readme
#
[tool.tbump]
github_url = "https://github.com/2i2c-org/binderhub-service"

[tool.tbump.version]
current = "0.1.0-0.dev"

# match our prerelease prefixes
# -alpha.1
# -beta.2
# -0.dev
regex = '''
(?P<major>\d+)
\.
(?P<minor>\d+)
\.
(?P<patch>\d+)
(\-
(?P<prelease>
(
(alpha|beta|rc)\.\d+|
0\.dev
)
)
)?
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "{new_version}"

[[tool.tbump.file]]
src = "chartpress.yaml"
search = 'baseVersion: "{current_version}"'
Loading

0 comments on commit b2786b9

Please sign in to comment.