Skip to content

Commit

Permalink
Merge pull request #34 from msfidelis/feature/argo
Browse files Browse the repository at this point in the history
Feature/argo
  • Loading branch information
msfidelis authored Oct 17, 2024
2 parents de9b82e + 0a63206 commit 32b9ca3
Show file tree
Hide file tree
Showing 24 changed files with 865 additions and 38 deletions.
26 changes: 26 additions & 0 deletions argocd.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "kubectl_manifest" "argo_projects" {

count = var.enable_argocd ? 1 : 0

yaml_body = <<YAML
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: ${var.cluster_name}
namespace: default
spec:
clusterResourceWhitelist:
- group: '*'
kind: '*'
destinations:
- namespace: '*'
server: '*'
sourceRepos:
- '*'
YAML

depends_on = [
helm_release.argocd
]

}
Binary file added helm/sample-0.1.0.tgz
Binary file not shown.
23 changes: 23 additions & 0 deletions helm/sample/.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 helm/sample/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: sample
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"
62 changes: 62 additions & 0 deletions helm/sample/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "sample.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 "sample.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 "sample.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "sample.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "sample.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Empty file.
16 changes: 16 additions & 0 deletions helm/sample/templates/istio-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: {{ .Values.app.name }}
namespace: {{ .Values.app.namespace }}
spec:
selector:
istio: {{ .Values.app.istio.gateway.selector }}
servers:
- hosts:
- {{ .Values.app.istio.host }}
port:
name: http
number: {{ .Values.app.istio.gateway.port }}
protocol: {{ .Values.app.istio.gateway.protocol }}
---
22 changes: 22 additions & 0 deletions helm/sample/templates/istio-virtual-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: {{ .Values.app.name }}
namespace: {{ .Values.app.namespace }}
spec:
gateways:
- {{ .Values.app.name }}
hosts:
- {{ .Values.app.istio.host }}
http:
- route:
- destination:
host: {{ .Values.app.name }}
port:
number: {{ .Values.app.port.port }}
retries:
attempts: {{ .Values.app.istio.virtualService.http.retries.attempts }}
perTryTimeout: {{ .Values.app.istio.virtualService.http.retries.perTryTimeout }}
retryOn: {{ .Values.app.istio.virtualService.http.retries.retryOn }}
---
8 changes: 8 additions & 0 deletions helm/sample/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: Namespace
metadata:
labels:
istio-injection: enabled
name: {{ .Values.app.namespace }}
---
57 changes: 57 additions & 0 deletions helm/sample/templates/rollouts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: {{ .Values.app.name }}
namespace: {{ .Values.app.namespace }}
spec:
replicas: {{ .Values.app.capacity.min }}
revisionHistoryLimit: 3
selector:
matchLabels:
app: {{ .Values.app.name }}
strategy:
{{- toYaml .Values.app.rollout.strategy | nindent 4 }}
template:
metadata:
annotations:
prometheus.io/port: "{{ .Values.app.prometheus.port }}"
prometheus.io/path: "{{ .Values.app.prometheus.path }}"
prometheus.io/scrape: "{{ .Values.app.prometheus.scrape }}"
labels:
app: {{ .Values.app.name }}
name: {{ .Values.app.name }}
version: {{ .Values.app.version }}
spec:
serviceAccountName: build-robot
containers:
- name: {{ .Values.app.name }}
ports:
- containerPort: {{ .Values.app.port.targetPort }}
name: {{ .Values.app.port.name }}
env:
{{- toYaml .Values.app.envs | nindent 8 }}
image: {{ .Values.app.image }}
resources:
requests:
cpu: {{ .Values.app.capacity.requests.cpu }}
memory: {{ .Values.app.capacity.requests.memory }}
limits:
cpu: {{ .Values.app.capacity.limits.cpu }}
memory: {{ .Values.app.capacity.limits.memory }}
{{- if .Values.app.probes.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.app.probes.livenessProbe.httpGet.path }}
port: {{ .Values.app.probes.livenessProbe.httpGet.port }}
failureThreshold: {{ .Values.app.probes.livenessProbe.failureThreshold }}
periodSeconds: {{ .Values.app.probes.livenessProbe.periodSeconds }}
{{- end }}
{{- if .Values.app.probes.startupProbe.enabled }}
startupProbe:
httpGet:
path: {{ .Values.app.probes.startupProbe.httpGet.path }}
port: {{ .Values.app.probes.startupProbe.httpGet.port }}
failureThreshold: {{ .Values.app.probes.startupProbe.failureThreshold }}
periodSeconds: {{ .Values.app.probes.startupProbe.periodSeconds }}
{{- end }}
7 changes: 7 additions & 0 deletions helm/sample/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
annotations:
eks.amazonaws.com/role-arn: {{ .Values.app.iam }}
name: {{ .Values.app.name }}
namespace: {{ .Values.app.namespace }}
18 changes: 18 additions & 0 deletions helm/sample/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.app.name }}
namespace: {{ .Values.app.namespace }}
labels:
annotations:
prometheus.io/port: "8080"
prometheus.io/scrape: "true"
spec:
type: {{ .Values.app.service.type }}
selector:
app: {{ .Values.app.name }}
ports:
- name: {{ .Values.app.port.name }}
port: {{ .Values.app.port.port }}
protocol: {{ .Values.app.port.protocol }}
targetPort: {{ int .Values.app.port.targetPort }}
80 changes: 80 additions & 0 deletions helm/sample/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
app:
name: nginx
image: nginx:latest
namespace: nginx
iam: ""
capacity:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi
autoscaling: {}
min: 1
max: 10
rollout:
strategy:
canary:
steps:
- setWeight: 20
- pause: { duration: 10 }
- setWeight: 40
- pause: { duration: 10 }
- setWeight: 60
- pause: { duration: 10 }
- setWeight: 80
- pause: { duration: 10 }
- setWeight: 100
envs:
- name: FOO
value: "bar"
- name: PING
value: "pong"

port:
name: web
port: 80
protocol: TCP
targetPort: 80
service:
type: ClusterIP
istio:
gateway:
selector: ingressgateway
# HTTP, HTTP2, GRPC, GRPC-WEB, MONGO, REDIS, MYSQL, TCP
protocol: HTTP
port: 80
host: nginx.k8s.raj.ninja
virtualService:
http:
enabled: true
retries:
attempts: 1
perTryTimeout: 500ms
retryOn: refused-stream
DestinationRule:
enabled: true

prometheus:
scrape: "true"
port: 80
path: /metrics

probes:
livenessProbe:
enabled: true
failureThreshold: 10
periodSeconds: 10
httpGet:
path: /
port: 80
startupProbe:
enabled: true
failureThreshold: 10
periodSeconds: 10
httpGet:
path: /
port: 80

kubernetesClusterDomain: cluster.local
Loading

0 comments on commit 32b9ca3

Please sign in to comment.