Skip to content

Commit

Permalink
init user controller helm charts by using helmify.
Browse files Browse the repository at this point in the history
  • Loading branch information
lingdie committed Sep 7, 2023
1 parent bc7c2fc commit 33e6df5
Show file tree
Hide file tree
Showing 21 changed files with 889 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controllers/user/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

HELMIFY ?= $(LOCALBIN)/helmify

.PHONY: helmify
helmify: $(HELMIFY) ## Download helmify locally if necessary.
$(HELMIFY): $(LOCALBIN)
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest

helm: manifests helmify
$(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir deploy/charts/user

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
Expand Down
23 changes: 23 additions & 0 deletions controllers/user/deploy/charts/user/.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/
21 changes: 21 additions & 0 deletions controllers/user/deploy/charts/user/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: user
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: "0.1.0"
55 changes: 55 additions & 0 deletions controllers/user/deploy/charts/user/crds/deleterequest-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
name: deleterequests.user.sealos.io
spec:
group: user.sealos.io
names:
kind: DeleteRequest
listKind: DeleteRequestList
plural: deleterequests
singular: deleterequest
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: DeleteRequest is the Schema for the deleterequests 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.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
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.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: DeleteRequestSpec defines the desired state of DeleteRequest
properties:
user:
type: string
type: object
status:
description: DeleteRequestStatus defines the observed state of DeleteRequest
properties:
phase:
enum:
- Pending
- Processing
- Completed
- Failed
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
82 changes: 82 additions & 0 deletions controllers/user/deploy/charts/user/crds/operationrequest-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
name: operationrequests.user.sealos.io
spec:
group: user.sealos.io
names:
kind: Operationrequest
listKind: OperationrequestList
plural: operationrequests
singular: operationrequest
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.action
name: Action
type: string
- jsonPath: .spec.user
name: User
type: string
- jsonPath: .spec.role
name: Role
type: string
- jsonPath: .status.phase
name: Phase
type: string
name: v1
schema:
openAPIV3Schema:
description: Operationrequest is the Schema for the operation requests 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.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
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.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: OperationrequestSpec defines the desired state of Operationrequest
properties:
action:
enum:
- Grant
- Update
- Deprive
type: string
role:
enum:
- Owner
- Manager
- Developer
type: string
user:
type: string
type: object
status:
description: OperationrequestStatus defines the observed state of Operationrequest
properties:
phase:
default: Pending
description: Phase is the recently observed lifecycle phase of operationrequest.
enum:
- Pending
- Processing
- Completed
- Failed
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
116 changes: 116 additions & 0 deletions controllers/user/deploy/charts/user/crds/user-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
name: users.user.sealos.io
spec:
group: user.sealos.io
names:
kind: User
listKind: UserList
plural: users
singular: user
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .status.phase
name: Phase
type: string
- jsonPath: .status.observedCSRExpirationSeconds
name: ExpirationSeconds
type: integer
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1
schema:
openAPIV3Schema:
description: User is the Schema for the users 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.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
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.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: UserSpec defines the desired state of User
properties:
csrExpirationSeconds:
default: 7200
description: "expirationSeconds is the requested duration of validity
of the issued certificate. The certificate signer may issue a certificate
with a different validity duration so a client must check the delta
between the notBefore and notAfter fields in the issued certificate
to determine the actual duration. \n The minimum valid value for
expirationSeconds is 600, i.e. 10 minutes."
format: int32
type: integer
type: object
status:
description: UserStatus defines the observed state of User
properties:
conditions:
description: Conditions contains the different condition statuses
for this user.
items:
properties:
lastHeartbeatTime:
description: LastHeartbeatTime is the last time this condition
was updated.
format: date-time
type: string
lastTransitionTime:
description: LastTransitionTime is the last time the condition
changed from one status to another.
format: date-time
type: string
message:
description: Message is a human-readable message indicating
details about the last status change.
type: string
reason:
description: Reason is a (brief) reason for the condition's
last status change.
type: string
status:
description: Status is the status of the condition. One of True,
False, Unknown.
type: string
type:
type: string
required:
- status
- type
type: object
type: array
kubeConfig:
type: string
observedCSRExpirationSeconds:
default: 7200
format: int32
type: integer
observedGeneration:
description: The generation observed by the user controller.
format: int64
type: integer
phase:
default: Unknown
description: Phase is the recently observed lifecycle phase of user
type: string
required:
- kubeConfig
type: object
type: object
served: true
storage: true
subresources:
status: {}
62 changes: 62 additions & 0 deletions controllers/user/deploy/charts/user/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "user.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 "user.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 "user.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "user.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "user.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Loading

0 comments on commit 33e6df5

Please sign in to comment.