Skip to content

Commit

Permalink
feat: add helm image, new make commands, update docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
ramantehlan committed Jun 4, 2024
1 parent b62cc41 commit 7c2b89e
Show file tree
Hide file tree
Showing 36 changed files with 835 additions and 26 deletions.
23 changes: 23 additions & 0 deletions charts/elasti/.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 charts/elasti/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: elasti
description: A Helm chart for Elasti tool. Elasti is used for auto-scaling Kubernetes services based on incoming requests.
# 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"
14 changes: 14 additions & 0 deletions charts/elasti/templates/EDS-access-binding-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "elasti.fullname" . }}-EDS-access-binding
labels:
{{- include "elasti.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: '{{ include "elasti.fullname" . }}-EDS-access'
subjects:
- kind: ServiceAccount
name: '{{ include "elasti.fullname" . }}-controller-manager'
namespace: '{{ .Release.Namespace }}'
39 changes: 39 additions & 0 deletions charts/elasti/templates/EDS-access-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "elasti.fullname" . }}-EDS-access
labels:
{{- include "elasti.labels" . | nindent 4 }}
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- watch
- apiGroups:
- discovery.k8s.io
resources:
- endpointslices
verbs:
- get
- list
- watch
- update
- patch
- delete
- create
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
- watch
- update
- patch
- delete
- create
62 changes: 62 additions & 0 deletions charts/elasti/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "elasti.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 "elasti.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 "elasti.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "elasti.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "elasti.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/elasti/templates/apiserver-node-access-binding-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "elasti.fullname" . }}-apiserver-node-access-binding
labels:
{{- include "elasti.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: '{{ include "elasti.fullname" . }}-apiserver-node-access'
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: kube-apiserver-kubelet-client
namespace: '{{ .Release.Namespace }}'
21 changes: 21 additions & 0 deletions charts/elasti/templates/apiserver-node-access-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "elasti.fullname" . }}-apiserver-node-access
labels:
{{- include "elasti.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- nodes/proxy
verbs:
- get
14 changes: 14 additions & 0 deletions charts/elasti/templates/controller-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "elasti.fullname" . }}-controller-service
labels:
control-plane: controller-manager
{{- include "elasti.labels" . | nindent 4 }}
spec:
type: {{ .Values.controllerService.type }}
selector:
control-plane: controller-manager
{{- include "elasti.selectorLabels" . | nindent 4 }}
ports:
{{- .Values.controllerService.ports | toYaml | nindent 2 }}
86 changes: 86 additions & 0 deletions charts/elasti/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "elasti.fullname" . }}-controller-manager
labels:
control-plane: controller-manager
{{- include "elasti.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.controllerManager.replicas }}
selector:
matchLabels:
control-plane: controller-manager
{{- include "elasti.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
control-plane: controller-manager
{{- include "elasti.selectorLabels" . | nindent 8 }}
annotations:
kubectl.kubernetes.io/default-container: manager
spec:
containers:
- args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }}
command:
- /manager
env:
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
| default .Chart.AppVersion }}
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
name: manager
ports:
- containerPort: 8013
name: metrics
protocol: TCP
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources: {{- toYaml .Values.controllerManager.manager.resources | nindent 10
}}
securityContext: {{- toYaml .Values.controllerManager.manager.containerSecurityContext
| nindent 10 }}
securityContext:
runAsNonRoot: true
serviceAccountName: {{ include "elasti.fullname" . }}-controller-manager
terminationGracePeriodSeconds: 10
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "elasti.fullname" . }}-resolver
labels:
{{- include "elasti.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.resolver.replicas }}
selector:
matchLabels:
app: resolver
{{- include "elasti.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: resolver
{{- include "elasti.selectorLabels" . | nindent 8 }}
spec:
containers:
- env:
- name: SYSTEM_NAMESPACE
value: {{ quote .Values.resolver.playground.env.systemNamespace }}
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
image: {{ .Values.resolver.playground.image.repository }}:{{ .Values.resolver.playground.image.tag
| default .Chart.AppVersion }}
name: playground
ports:
- containerPort: 8012
resources: {{- toYaml .Values.resolver.playground.resources | nindent 10 }}
82 changes: 82 additions & 0 deletions charts/elasti/templates/elastiservice-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: elastiservices.elasti.truefoundry.io
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
labels:
{{- include "elasti.labels" . | nindent 4 }}
spec:
group: elasti.truefoundry.io
names:
kind: ElastiService
listKind: ElastiServiceList
plural: elastiservices
singular: elastiservice
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ElastiService is the Schema for the elastiservices 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: ElastiServiceSpec defines the desired state of ElastiService
properties:
deploymentName:
type: string
idlePeriod:
description: Idle Period is how long should the target VirtualService
be Idle(without requests), before we scale it down to 0.
format: int32
type: integer
queueTimeout:
description: How long do playground hold the request for, before dumping
the queue. Default is 60s.
format: int32
type: integer
service:
type: string
type: object
status:
description: ElastiServiceStatus defines the observed state of ElastiService
properties:
lastReconciledTime:
description: |-
INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Important: Run "make" to regenerate code after modifying this file
format: date-time
type: string
mode:
type: string
state:
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit 7c2b89e

Please sign in to comment.