From 15387b41a1defae7ab36049a3c7d1e8d1d753fad Mon Sep 17 00:00:00 2001 From: "Evan J. Felix" Date: Thu, 3 Oct 2019 16:50:40 -0700 Subject: [PATCH 1/2] add nginx-app basic chart --- charts/charts/nginx-app/.helmignore | 22 ++++++++ charts/charts/nginx-app/Chart.yaml | 5 ++ charts/charts/nginx-app/DISCLAIMER | 8 +++ charts/charts/nginx-app/LICENSE | 7 +++ charts/charts/nginx-app/README.md | 26 ++++++++++ charts/charts/nginx-app/templates/NOTES.txt | 19 +++++++ .../charts/nginx-app/templates/_helpers.tpl | 32 ++++++++++++ .../nginx-app/templates/deployment.yaml | 51 +++++++++++++++++++ .../charts/nginx-app/templates/ingress.yaml | 38 ++++++++++++++ .../charts/nginx-app/templates/service.yaml | 19 +++++++ charts/charts/nginx-app/values.yaml | 43 ++++++++++++++++ 11 files changed, 270 insertions(+) create mode 100644 charts/charts/nginx-app/.helmignore create mode 100644 charts/charts/nginx-app/Chart.yaml create mode 100644 charts/charts/nginx-app/DISCLAIMER create mode 100644 charts/charts/nginx-app/LICENSE create mode 100644 charts/charts/nginx-app/README.md create mode 100644 charts/charts/nginx-app/templates/NOTES.txt create mode 100644 charts/charts/nginx-app/templates/_helpers.tpl create mode 100644 charts/charts/nginx-app/templates/deployment.yaml create mode 100644 charts/charts/nginx-app/templates/ingress.yaml create mode 100644 charts/charts/nginx-app/templates/service.yaml create mode 100644 charts/charts/nginx-app/values.yaml diff --git a/charts/charts/nginx-app/.helmignore b/charts/charts/nginx-app/.helmignore new file mode 100644 index 0000000..9651f65 --- /dev/null +++ b/charts/charts/nginx-app/.helmignore @@ -0,0 +1,22 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj +charts/ diff --git a/charts/charts/nginx-app/Chart.yaml b/charts/charts/nginx-app/Chart.yaml new file mode 100644 index 0000000..34879e4 --- /dev/null +++ b/charts/charts/nginx-app/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Simple Web service Chart +name: nginx-app +version: 0.1.0 diff --git a/charts/charts/nginx-app/DISCLAIMER b/charts/charts/nginx-app/DISCLAIMER new file mode 100644 index 0000000..7be185c --- /dev/null +++ b/charts/charts/nginx-app/DISCLAIMER @@ -0,0 +1,8 @@ +This material was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of their employees, nor any jurisdiction or organization that has cooperated in the development of these materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents that its use would not infringe privately owned rights. +Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof. +PACIFIC NORTHWEST NATIONAL LABORATORY +operated by +BATTELLE +for the +UNITED STATES DEPARTMENT OF ENERGY +under Contract DE-AC05-76RL01830 \ No newline at end of file diff --git a/charts/charts/nginx-app/LICENSE b/charts/charts/nginx-app/LICENSE new file mode 100644 index 0000000..e085f4d --- /dev/null +++ b/charts/charts/nginx-app/LICENSE @@ -0,0 +1,7 @@ +Copyright © 2019, Battelle Memorial Institute +All rights reserved. +1. Battelle Memorial Institute (hereinafter Battelle) hereby grants permission to any person or entity lawfully obtaining a copy of this software and associated documentation files (hereinafter "the Software") to redistribute and use the Software in source and binary forms, with or without modification. Such person or entity may use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and may permit others to do so, subject to the following conditions: +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Other than as used herein, neither the name Battelle Memorial Institute or Battelle may be used in any form whatsoever without the express written consent of Battelle. +2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BATTELLE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/charts/charts/nginx-app/README.md b/charts/charts/nginx-app/README.md new file mode 100644 index 0000000..b3ee033 --- /dev/null +++ b/charts/charts/nginx-app/README.md @@ -0,0 +1,26 @@ +# NGINX App chart + +This chart allows you to deploy a simple web application container running nginx, and provides a service and ingress to the application + + +## Install Chart + +To install the Chart into your Kubernetes cluster : + +```bash +helm install --name "mywebapp" pnnl-miscscripts/chronyd --set image.repository=nginx +``` + +After installation succeeds, you can get a status of Chart + +```bash +helm status "mywebapp" +``` + +If you want to delete your Chart, use this command: + +```bash +helm delete --purge "mywebapp" +``` + + diff --git a/charts/charts/nginx-app/templates/NOTES.txt b/charts/charts/nginx-app/templates/NOTES.txt new file mode 100644 index 0000000..4c29ffe --- /dev/null +++ b/charts/charts/nginx-app/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "nginx-app.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 svc -w {{ template "nginx-app.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "nginx-app.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + 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={{ template "nginx-app.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/charts/nginx-app/templates/_helpers.tpl b/charts/charts/nginx-app/templates/_helpers.tpl new file mode 100644 index 0000000..4cea259 --- /dev/null +++ b/charts/charts/nginx-app/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "pnnlmiscscripts.nginx-app.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 "pnnlmiscscripts.nginx-app.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 "pnnlmiscscripts.nginx-app.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/charts/charts/nginx-app/templates/deployment.yaml b/charts/charts/nginx-app/templates/deployment.yaml new file mode 100644 index 0000000..e506fcf --- /dev/null +++ b/charts/charts/nginx-app/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "pnnlmiscscripts.nginx-app.fullname" . }} + labels: + app: {{ template "pnnlmiscscripts.nginx-app.name" . }} + chart: {{ template "pnnlmiscscripts.nginx-app.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "pnnlmiscscripts.nginx-app.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "pnnlmiscscripts.nginx-app.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + 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 | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/charts/charts/nginx-app/templates/ingress.yaml b/charts/charts/nginx-app/templates/ingress.yaml new file mode 100644 index 0000000..406c2cf --- /dev/null +++ b/charts/charts/nginx-app/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "pnnlmiscscripts.nginx-app.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "pnnlmiscscripts.nginx-app.name" . }} + chart: {{ template "pnnlmiscscripts.nginx-app.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- end }} diff --git a/charts/charts/nginx-app/templates/service.yaml b/charts/charts/nginx-app/templates/service.yaml new file mode 100644 index 0000000..54212e7 --- /dev/null +++ b/charts/charts/nginx-app/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "pnnlmiscscripts.nginx-app.fullname" . }} + labels: + app: {{ template "pnnlmiscscripts.nginx-app.name" . }} + chart: {{ template "pnnlmiscscripts.nginx-app.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "pnnlmiscscripts.nginx-app.name" . }} + release: {{ .Release.Name }} diff --git a/charts/charts/nginx-app/values.yaml b/charts/charts/nginx-app/values.yaml new file mode 100644 index 0000000..ac3e6e3 --- /dev/null +++ b/charts/charts/nginx-app/values.yaml @@ -0,0 +1,43 @@ +# Default values for nginx-app. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + tag: latest + pullPolicy: Always + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + annotations: + path: / + hosts: + - nginx-app.example.com +# tls: +# - secretName: example-com-tls +# hosts: +# - nginx-app.example.com + +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: {} + +tolerations: [] + +affinity: {} From 38e214df15444ef844181e6d262ba8ffc72893d6 Mon Sep 17 00:00:00 2001 From: "Evan J. Felix" Date: Fri, 4 Oct 2019 08:45:59 -0700 Subject: [PATCH 2/2] add travis build --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index f951c51..a248c3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,11 @@ jobs: language: shell name: Build chronyd container script: ./containers/build chronyd + - stage: build + dist: xenial + language: shell + name: Build nginx-add container + script: ./containers/build nginix-app - stage: build dist: xenial language: shell