Skip to content

Commit

Permalink
Add templates
Browse files Browse the repository at this point in the history
Signed-off-by: d-kuro <[email protected]>
  • Loading branch information
d-kuro committed Aug 14, 2021
1 parent cd1c38f commit 0fc9c07
Show file tree
Hide file tree
Showing 18 changed files with 562 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/accurate/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
24 changes: 24 additions & 0 deletions charts/accurate/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: accurate
description: Accurate is a Kubernetes controller for soft multi-tenancy environments.

# 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: 0.1.0
43 changes: 43 additions & 0 deletions charts/accurate/crds/accurate.cybozu.com_subnamespaces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.6.1
labels:
app.kubernetes.io/name: accurate
name: subnamespaces.accurate.cybozu.com
spec:
group: accurate.cybozu.com
names:
kind: SubNamespace
listKind: SubNamespaceList
plural: subnamespaces
singular: subnamespace
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: SubNamespace is the Schema for the subnamespaces API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.'
type: string
metadata:
type: object
status:
description: Status is the status of SubNamespace.
enum:
- ok
- conflict
type: string
type: object
served: true
storage: true
Empty file.
62 changes: 62 additions & 0 deletions charts/accurate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "accurate.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 "accurate.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 "accurate.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "accurate.labels" -}}
helm.sh/chart: {{ include "accurate.chart" . }}
{{ include "accurate.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "accurate.selectorLabels" -}}
app.kubernetes.io/name: {{ include "accurate.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "accurate.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "accurate.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/accurate/templates/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ template "accurate.fullname" . }}-serving-cert
namespace: {{ .Release.Namespace }}
labels:
{{- include "accurate.labels" . | nindent 4 }}
spec:
dnsNames:
- {{ template "accurate.fullname" . }}-webhook-service.{{ .Release.Namespace }}.svc
- {{ template "accurate.fullname" . }}-webhook-service.{{ .Release.Namespace }}.svc.cluster.local
issuerRef:
kind: Issuer
name: {{ template "accurate.fullname" . }}-selfsigned-issuer
secretName: {{ template "accurate.fullname" . }}-webhook-server-cert
96 changes: 96 additions & 0 deletions charts/accurate/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "accurate.fullname" . }}-manager-role
labels:
{{- include "accurate.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- namespaces
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- accurate.cybozu.com
resources:
- subnamespaces
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- accurate.cybozu.com
resources:
- subnamespaces/finalizers
verbs:
- update
- apiGroups:
- accurate.cybozu.com
resources:
- subnamespaces/status
verbs:
- get
- patch
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "accurate.fullname" . }}-subnamespace-editor-role
labels:
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
{{- include "accurate.labels" . | nindent 4 }}
rules:
- apiGroups:
- accurate.cybozu.com
resources:
- subnamespaces
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- accurate.cybozu.com
resources:
- subnamespaces/status
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "accurate.fullname" . }}-subnamespace-viewer-role
labels:
rbac.authorization.k8s.io/aggregate-to-view: "true"
{{- include "accurate.labels" . | nindent 4 }}
rules:
- apiGroups:
- accurate.cybozu.com
resources:
- subnamespaces
verbs:
- get
- list
- watch
- apiGroups:
- accurate.cybozu.com
resources:
- subnamespaces/status
verbs:
- get
29 changes: 29 additions & 0 deletions charts/accurate/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "accurate.fullname" . }}-manager-admin
labels:
{{- include "accurate.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: admin
subjects:
- kind: ServiceAccount
name: {{ template "accurate.fullname" . }}-controller-manager
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "accurate.fullname" . }}-manager-rolebinding
labels:
{{- include "accurate.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "accurate.fullname" . }}-manager-role
subjects:
- kind: ServiceAccount
name: {{ template "accurate.fullname" . }}-controller-manager
namespace: {{ .Release.Namespace }}
28 changes: 28 additions & 0 deletions charts/accurate/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "accurate.fullname" . }}-config
namespace: {{ .Release.Namespace }}
data:
config.yaml: |
# Labels to be propagated to sub-namespaces.
labelKeys:
- team
# Annotations to be propagated to sub-namespaces.
annotationKeys:
# An example to propagate an annotation for MetalLB
# https://metallb.universe.tf/usage/#requesting-specific-ips
- metallb.universe.tf/address-pool
# List of GVK for namespace-scoped resources that can be propagated.
# Any namespace-scoped resource is allowed.
watches:
- group: rbac.authorization.k8s.io
version: v1
kind: Role
- group: rbac.authorization.k8s.io
version: v1
kind: RoleBinding
- version: v1
kind: Secret
Loading

0 comments on commit 0fc9c07

Please sign in to comment.