From 61e2a09dce61a4eeb1ad627aef7b0771fd293f4a Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Fri, 30 Dec 2022 15:31:29 +0100 Subject: [PATCH] feat: initial version --- .concourse/pipeline.yml | 46 ++++++++++++ .concourse/tasks/image.yml | 28 +++++++ Dockerfile | 15 ++++ archetypes/default.md | 6 ++ assets/.gitkeep | 0 config.toml | 19 +++++ content/01-installation/01-basics.md | 8 ++ content/01-installation/_index.md | 19 +++++ content/02-configuration/01-listeners.md | 8 ++ content/02-configuration/_index.md | 6 ++ content/03-architecture/_index.md | 6 ++ content/_index.md | 1 + data/.gitkeep | 0 deploy/helm/.helmignore | 23 ++++++ deploy/helm/Chart.yaml | 24 ++++++ deploy/helm/templates/_helpers.tpl | 62 +++++++++++++++ deploy/helm/templates/deployment.yaml | 58 ++++++++++++++ deploy/helm/templates/ingress.yaml | 61 +++++++++++++++ deploy/helm/templates/service.yaml | 15 ++++ .../helm/templates/tests/test-connection.yaml | 15 ++++ deploy/helm/values.yaml | 75 +++++++++++++++++++ go.mod | 5 ++ go.sum | 2 + layouts/partials/logo.html | 54 +++++++++++++ 24 files changed, 556 insertions(+) create mode 100644 .concourse/pipeline.yml create mode 100644 .concourse/tasks/image.yml create mode 100644 Dockerfile create mode 100644 archetypes/default.md create mode 100644 assets/.gitkeep create mode 100644 config.toml create mode 100644 content/01-installation/01-basics.md create mode 100644 content/01-installation/_index.md create mode 100644 content/02-configuration/01-listeners.md create mode 100644 content/02-configuration/_index.md create mode 100644 content/03-architecture/_index.md create mode 100644 content/_index.md create mode 100644 data/.gitkeep create mode 100644 deploy/helm/.helmignore create mode 100644 deploy/helm/Chart.yaml create mode 100644 deploy/helm/templates/_helpers.tpl create mode 100644 deploy/helm/templates/deployment.yaml create mode 100644 deploy/helm/templates/ingress.yaml create mode 100644 deploy/helm/templates/service.yaml create mode 100644 deploy/helm/templates/tests/test-connection.yaml create mode 100644 deploy/helm/values.yaml create mode 100644 go.mod create mode 100644 go.sum create mode 100644 layouts/partials/logo.html diff --git a/.concourse/pipeline.yml b/.concourse/pipeline.yml new file mode 100644 index 0000000..e804023 --- /dev/null +++ b/.concourse/pipeline.yml @@ -0,0 +1,46 @@ +--- +resource_types: +- name: helm + type: docker-image + source: + repository: ghcr.io/typositoire/concourse-helm3-resource + +resources: +- name: inetmock-docs.git + type: git + icon: github + source: + uri: https://code.icb4dc0.de/inetmock/docs.git + +- name: caddy-image + type: docker-image + source: + repository: code.icb4dc0.de/prskr/ci-images/caddy + +- name: blog-chart + type: helm + source: + cluster_url: ((k8s-credentials.url)) + cluster_ca: ((k8s-credentials.ca-crt)) + token: ((k8s-credentials.token)) + release: docs + namespace: inetmock + +jobs: +- name: build + plan: + - get: inetmock-docs.git + trigger: true + - get: caddy-image + trigger: true + - task: build-container-image + file: inetmock-docs.git/.concourse/tasks/image.yml + input_mapping: {repo: inetmock-docs.git} + + - put: blog-chart + params: + chart: inetmock-docs.git/deploy/helm + override_values: + - key: image.tag + path: inetmock-docs.git/.git/ref + type: string \ No newline at end of file diff --git a/.concourse/tasks/image.yml b/.concourse/tasks/image.yml new file mode 100644 index 0000000..74e0795 --- /dev/null +++ b/.concourse/tasks/image.yml @@ -0,0 +1,28 @@ +--- +platform: linux + +image_resource: + name: kaniko-debug + type: registry-image + source: + repository: gcr.io/kaniko-project/executor + tag: debug + +inputs: + - name: repo + path: . + +params: + GITEA_USER: ((gitea-credentials.user)) + GITEA_TOKEN: ((gitea-credentials.token)) + +run: + path: sh + args: + - -ce + - | + echo "{\"auths\": {\"https://code.icb4dc0.de\": {\"auth\" : \"$(printf '%s:%s' $GITEA_USER $GITEA_TOKEN | base64)\" }}}" > /kaniko/.docker/config.json + /kaniko/executor \ + --destination code.icb4dc0.de/inetmock/docs:latest \ + --destination code.icb4dc0.de/inetmock/docs:$(cat .git/ref) \ + --context . \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c2b2f50 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM docker.io/golang:1.19-alpine as builder + +WORKDIR /tmp + +RUN apk add -U --no-cache hugo git + +WORKDIR /src + +COPY . /src/ + +RUN hugo --minify --environment production --config config.toml + +FROM code.icb4dc0.de/prskr/ci-images/caddy:latest as final + +COPY --from=builder /src/public /usr/share/caddy \ No newline at end of file diff --git a/archetypes/default.md b/archetypes/default.md new file mode 100644 index 0000000..00e77bd --- /dev/null +++ b/archetypes/default.md @@ -0,0 +1,6 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +date: {{ .Date }} +draft: true +--- + diff --git a/assets/.gitkeep b/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..a58a006 --- /dev/null +++ b/config.toml @@ -0,0 +1,19 @@ +baseURL = 'https://inetmock.icb4dc0.de/docs/' +languageCode = 'en-us' +theme = ['github.com/McShelby/hugo-theme-relearn'] +pluralizelisttitles = false +title = "INetMock" + +[Params] +author = "Peter Kurfer" +description = "INetMock docs" +style= "auto" +copyCodeButton = true +rssAsSocialIcon = true +ordersectionsby = "weight" +themeVariant = "relearn-light" +collapsibleMenu = true + + +[outputs] +home = [ "HTML", "RSS", "JSON"] \ No newline at end of file diff --git a/content/01-installation/01-basics.md b/content/01-installation/01-basics.md new file mode 100644 index 0000000..7066fee --- /dev/null +++ b/content/01-installation/01-basics.md @@ -0,0 +1,8 @@ ++++ +title = "Basics" +chapter = true +weight = 15 +pre = "1. " ++++ + +# Basics \ No newline at end of file diff --git a/content/01-installation/_index.md b/content/01-installation/_index.md new file mode 100644 index 0000000..e9bf686 --- /dev/null +++ b/content/01-installation/_index.md @@ -0,0 +1,19 @@ ++++ +title = "Installation" +chapter = true +weight = 10 +pre = "1. " ++++ + +# Installation + +INetMock can be installed either as a container e.g. with Podman or Docker, as a *systemd* service or with any other run system. + +## Requirements + +The INetMock server currently only works on Linux. +This has a variety of reasons but the most significant one is that the eBPF components (currently) only work on Linux although Microsoft is working on bringing some capabilities to Windows as well but that might still take some time. + +Development of INetMock is mostly done on Arch Linux and CI runs on Ubuntu 22.04. +Latest Fedora version should also work. +INetMock can work also on Ubuntu 20.04 but only if you updated your kernel. \ No newline at end of file diff --git a/content/02-configuration/01-listeners.md b/content/02-configuration/01-listeners.md new file mode 100644 index 0000000..8be8297 --- /dev/null +++ b/content/02-configuration/01-listeners.md @@ -0,0 +1,8 @@ ++++ +title = "Listeners" +chapter = true +weight = 15 +pre = "1. " ++++ + +# Listeners \ No newline at end of file diff --git a/content/02-configuration/_index.md b/content/02-configuration/_index.md new file mode 100644 index 0000000..9d5663e --- /dev/null +++ b/content/02-configuration/_index.md @@ -0,0 +1,6 @@ ++++ +title = "Configuration" +chapter = true +weight = 20 +pre = "2. " ++++ \ No newline at end of file diff --git a/content/03-architecture/_index.md b/content/03-architecture/_index.md new file mode 100644 index 0000000..afe4375 --- /dev/null +++ b/content/03-architecture/_index.md @@ -0,0 +1,6 @@ ++++ +title = "Architecture" +chapter = true +weight = 30 +pre = "3. " ++++ \ No newline at end of file diff --git a/content/_index.md b/content/_index.md new file mode 100644 index 0000000..4166be3 --- /dev/null +++ b/content/_index.md @@ -0,0 +1 @@ +# INetMock documentation \ No newline at end of file diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/deploy/helm/.helmignore b/deploy/helm/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/deploy/helm/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deploy/helm/Chart.yaml b/deploy/helm/Chart.yaml new file mode 100644 index 0000000..7a9cdfa --- /dev/null +++ b/deploy/helm/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: inetmock-docs +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" diff --git a/deploy/helm/templates/_helpers.tpl b/deploy/helm/templates/_helpers.tpl new file mode 100644 index 0000000..561c588 --- /dev/null +++ b/deploy/helm/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "inetmock-docs.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +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 "inetmock-docs.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "inetmock-docs.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "inetmock-docs.labels" -}} +helm.sh/chart: {{ include "inetmock-docs.chart" . }} +{{ include "inetmock-docs.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "inetmock-docs.selectorLabels" -}} +app.kubernetes.io/name: {{ include "inetmock-docs.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "inetmock-docs.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "inetmock-docs.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yaml new file mode 100644 index 0000000..e468b78 --- /dev/null +++ b/deploy/helm/templates/deployment.yaml @@ -0,0 +1,58 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "inetmock-docs.fullname" . }} + labels: + {{- include "inetmock-docs.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "inetmock-docs.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "inetmock-docs.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deploy/helm/templates/ingress.yaml b/deploy/helm/templates/ingress.yaml new file mode 100644 index 0000000..23b1576 --- /dev/null +++ b/deploy/helm/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "inetmock-docs.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") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "inetmock-docs.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deploy/helm/templates/service.yaml b/deploy/helm/templates/service.yaml new file mode 100644 index 0000000..5f06a37 --- /dev/null +++ b/deploy/helm/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "inetmock-docs.fullname" . }} + labels: + {{- include "inetmock-docs.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "inetmock-docs.selectorLabels" . | nindent 4 }} diff --git a/deploy/helm/templates/tests/test-connection.yaml b/deploy/helm/templates/tests/test-connection.yaml new file mode 100644 index 0000000..999125d --- /dev/null +++ b/deploy/helm/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "inetmock-docs.fullname" . }}-test-connection" + labels: + {{- include "inetmock-docs.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "inetmock-docs.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml new file mode 100644 index 0000000..e019f48 --- /dev/null +++ b/deploy/helm/values.yaml @@ -0,0 +1,75 @@ +# Default values for inetmock-docs. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 2 + +image: + repository: code.icb4dc0.de/inetmock/docs + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +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: 65532 + +service: + type: ClusterIP + port: 3000 + +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: 60Mi + requests: + cpu: 50m + memory: 20Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..584e865 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module code.icb4dc0.de/inetmock/docs + +go 1.19 + +require github.com/McShelby/hugo-theme-relearn v0.0.0-20221230001326-0bed2a7096e6 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4fbeab8 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/McShelby/hugo-theme-relearn v0.0.0-20221230001326-0bed2a7096e6 h1:7PTU2Xv90O3dEgTfUUbbinYnRutQ5RpwnlnkgZmsM5M= +github.com/McShelby/hugo-theme-relearn v0.0.0-20221230001326-0bed2a7096e6/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM= diff --git a/layouts/partials/logo.html b/layouts/partials/logo.html new file mode 100644 index 0000000..cb2d5df --- /dev/null +++ b/layouts/partials/logo.html @@ -0,0 +1,54 @@ + + \ No newline at end of file