Compare commits

...

16 Commits

Author SHA1 Message Date
52161483de 'update files with ansible' 2022-01-30 11:23:40 +00:00
4449df2af7 'update files with ansible' 2021-10-26 11:41:56 +00:00
330eb43b21 'update files with ansible' 2021-05-17 13:43:30 +00:00
a8ef76913b 'update files with ansible' 2021-05-11 06:54:12 +00:00
401c2b9c14 'update files with ansible' 2021-04-12 14:15:04 +00:00
c889830bf1 'update files with ansible' 2021-04-01 05:46:20 +00:00
Jon Ervine
2ca3e8bf73 fixed dirs 2021-03-31 22:24:20 +08:00
Jon Ervine
cebc23b0c1 Add chart 2021-03-31 22:18:50 +08:00
2a6f78183c 'update files with ansible' 2021-03-31 12:54:58 +00:00
fa0f2a724b 'update files with ansible' 2021-03-31 03:27:50 +00:00
c208d9d14a 'update files with ansible' 2021-03-30 12:48:23 +00:00
a42cd588f2 'update files with ansible' 2021-03-30 12:37:46 +00:00
9994122767 'update files with ansible' 2021-03-30 12:27:30 +00:00
92daa0ff54 'update files with ansible' 2021-03-11 12:56:18 +00:00
b6b50ad74d 'update files with ansible' 2021-03-11 12:51:14 +00:00
7e1c81ae09 Merge pull request 'issue-#2' (#4) from issue-#2 into master
Reviewed-on: #4
2020-12-18 06:34:10 +00:00
11 changed files with 321 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# Base on latest (edge) alpine image
FROM harbor.ervine.dev/public/x86_64/alpine:v3.12
LABEL MAINTAINER="Jonathan Ervine <docker@ervine.org>"
FROM harbor.ervine.dev/public/x86_64/alpine:v3.15.0
LABEL MAINTAINER="Jonathan Ervine docker@ervine.org"
# Install updates
ENV LANG='en_US.UTF-8' \
@ -10,15 +10,15 @@ ENV LANG='en_US.UTF-8' \
RUN apk update && \
apk -U upgrade --ignore alpine-baselayout && \
apk -U add python3 gcc py3-pip python3-dev musl-dev libffi-dev git curl && \
adduser -D python && \
mkdir /data && cd /data && git clone --single-branch --branch master https://git.ervine.org/jonny/flask-python-helm /data && \
adduser -D helm-web && \
mkdir /data && cd /data && git clone --single-branch --branch master https://git.ervine.org/jonny/flask-python-helm.git /data && \
pip3 install -r /data/requirements.txt && \
curl -L https://get.helm.sh/helm-v3.4.2-linux-amd64.tar.gz -o /tmp/helm.tgz && \
curl -L https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz -o /tmp/helm.tgz && \
tar -zxvf /tmp/helm.tgz --strip-components=1 -C /usr/local/bin linux-amd64/helm && \
rm -rf /tmp/src && rm -rf /var/cache/apk/*
EXPOSE 3000
#USER python
#USER helm-web
CMD [ "/usr/bin/python3", "/data/main.py" ]

6
Jenkinsfile vendored
View File

@ -3,7 +3,7 @@ kind: Pod
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug-539ddefcae3fd6b411a95982a830d987f4214251
image: gcr.io/kaniko-project/executor:debug
imagePullPolicy: Always
command:
- /busybox/cat
@ -27,11 +27,11 @@ spec:
stage('Build with Kaniko') {
git branch: 'master', url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-helm-python.git', credentialsId: 'jenkins-to-git'
container('kaniko') {
sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=false --destination=harbor.ervine.dev/public/x86_64/alpine/helm-3:v3.12.1 --destination=harbor.ervine.dev/public/x86_64/alpine/helm-3:v3.12'
sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=false --destination=harbor.ervine.dev/public/x86_64/alpine/helm-3:v3.7.1 --destination=harbor.ervine.dev/public/x86_64/alpine/helm-3:v3.15.0'
}
}
stage('Notify gchat') {
hangoutsNotify message: "Helm python flask Application on Alpine Linux 3.12.1 has built",token: "A2ET831pVslqXTqAx6ycu573r",threadByJob: false
hangoutsNotify message: "Helm python flask application on Alpine Linux 3.15.0 has built",token: "A2ET831pVslqXTqAx6ycu573r",threadByJob: false
}
}
}

21
chart/helm-web/Chart.yaml Normal file
View File

@ -0,0 +1,21 @@
apiVersion: v2
name: helm-web
description: A Helm chart for the helm-web application
# 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.
version: 0.1
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 0.1

View File

@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "helm-web.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "helm-web.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "helm-web.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm-web.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}

View File

@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "helm-web.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 "helm-web.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 "helm-web.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "helm-web.labels" -}}
helm.sh/chart: {{ include "helm-web.chart" . }}
{{ include "helm-web.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "helm-web.selectorLabels" -}}
app.kubernetes.io/name: {{ include "helm-web.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "helm-web.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "helm-web.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

View File

@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "helm-web.fullname" . }}
labels:
{{- include "helm-web.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "helm-web.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "helm-web.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "helm-web.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
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 }}

View File

@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "helm-web.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- 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 "helm-web.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- 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: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "helm-web.fullname" . }}
labels:
{{- include "helm-web.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "helm-web.selectorLabels" . | nindent 4 }}

View File

@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "helm-web.serviceAccountName" . }}
labels:
{{- include "helm-web.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "helm-web.fullname" . }}-test-connection"
labels:
{{- include "helm-web.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "helm-web.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

View File

@ -0,0 +1,69 @@
# Default values for helm-web.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: jervinegogo/python-helm-web
pullPolicy: Always
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:
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 3000
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
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: 128Mi
requests:
cpu: 100m
memory: 128Mi
nodeSelector:
appenv: infra
tolerations: []
affinity: {}