Skip to content

Commit

Permalink
Contribution of puppet-forge to incubator Charts (helm#2542)
Browse files Browse the repository at this point in the history
* Contribution of puppet-forge to incubator Charts

* Fix whitespace in values.yaml
  • Loading branch information
hickey authored and Vic Iglesias committed Nov 22, 2017
1 parent 77b7ca0 commit ad98657
Show file tree
Hide file tree
Showing 11 changed files with 353 additions and 0 deletions.
21 changes: 21 additions & 0 deletions incubator/puppet-forge/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
13 changes: 13 additions & 0 deletions incubator/puppet-forge/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
description: Distribute locally developed Puppet modules and proxy to the official Puppet Forge server
name: puppet-forge
version: 0.1.7
appVersion: 1.10.0
home: https://github.com/unibet/puppet-forge-server
keywords:
- puppet
- repository
- forge
maintainers:
- name: Gerard Hickey
email: hickey@kinetic-compute.com
53 changes: 53 additions & 0 deletions incubator/puppet-forge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Helm Chart: puppet-forge
-----------------------
Distribute locally developed Puppet modules and proxy to the official Puppet Forge server.

Container for running the puppet_forge_server project from Github. This
project allow one to serve locally developed Puppet forge modules and
proxy requests to an upstream Puppet forge server (typically the official
server run by Puppetlabs).

How to use this container
-------------------------
The container when invoked with no arguments will start the Puppet forge
server at port 8080 with local Puppet forge modules locate in /puppet/modules.
If a volume mount is not specified to /puppet/modules, then all modules are
kept within the container and will the modules will be purged upon restarting
the container. In addition, the log files for the service are kept in
/puppet/logs.

The minimal command line to start the service is
````
docker run -d -p 8080:8080 puppet_forge
````

If any arguments are provided after the container name and begin with a dash,
then the arguments are provided as arguments to the Puppet forge server.
Otherwise the arguments are executed as a command within the context of the
container.

In addition there are a couple of meta-commands that the container will
respond to. If readme, info, or help (all case insensitive) are specified
as the first argument, then this README file will be displayed. Also if
the argument is version, then the current Puppet forge server version is
printed.

Configuration
-------------
Configuration of the Puppet forge container is controlled through a number
of environmental variables. This is normally done with the -e argument to
Docker.

Variable | Default Value | Notes
------------------------------|---------------|--------------------------------
PUPPET_FORGE_PROXY="URL" | None | Enable proxy mode to URL
PUPPET_FORGE_CACHE_TTL="SECS" | 1800 | Specify cache timeout in secs
PUPPET_FORGE_CACHE_SIZE="NUM" | 250 | Number of cache entries to keep
PUPPET_FORGE_MODULE_DIR="DIR" | /puppet/modules | Local module storage

Multiple directories can be specified for the module directory by setting the
value of the variable the list of directories with a colon (':') as the
delimiter. This can be useful if one has multiple module repositories that
allow module promotion. The server does not provide any access control for
multiple repositories and needs to be controlled through the Puppetfile.

23 changes: 23 additions & 0 deletions incubator/puppet-forge/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.hosts }}
{{- range .Values.ingress.hosts }}
http://{{ .name }}/{{ default "/" .path }}
{{- end }}
{{- else }}
Unable to detect host path or NodePort values from the ingress resource.
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "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 "fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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:{{ .Values.service.externalPort }}
{{- end }}
16 changes: 16 additions & 0 deletions incubator/puppet-forge/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "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).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
15 changes: 15 additions & 0 deletions incubator/puppet-forge/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fullname" . }}-config
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
puppet_forge_proxy: {{ .Values.puppet_forge.url }}
puppet_forge_cache_ttl: {{ .Values.puppet_forge.cache.ttl | quote }}
puppet_forge_cache_size: {{ .Values.puppet_forge.cache.size | quote }}
# puppet_forge_module_dir: {{ .Values.puppet_forge.module_dir }}
79 changes: 79 additions & 0 deletions incubator/puppet-forge/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "name" . }}
release: {{ .Release.Name }}
spec:
initContainers:
- name: prep-volume
image: busybox
command:
- chown
- -R
- 1000:1000
- /puppet
volumeMounts:
{{- if .Values.persistence.enabled }}
- mountPath: /puppet/modules
name: {{ .Release.Name }}-volume
readOnly: false
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: PUPPET_FORGE_PROXY
valueFrom:
configMapKeyRef:
name: {{ template "fullname" . }}-config
key: puppet_forge_proxy
- name: PUPPET_FORGE_CACHE_TTL
valueFrom:
configMapKeyRef:
name: {{ template "fullname" . }}-config
key: puppet_forge_cache_ttl
- name: PUPPET_FORGE_CACHE_SIZE
valueFrom:
configMapKeyRef:
name: {{ template "fullname" . }}-config
key: puppet_forge_cache_size
ports:
- containerPort: {{ .Values.service.internalPort }}
livenessProbe:
httpGet:
path: /
port: {{ .Values.service.internalPort }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.service.internalPort }}
volumeMounts:
{{- if .Values.persistence.enabled }}
- mountPath: /puppet/modules
name: {{ .Release.Name }}-volume
readOnly: false
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
volumes:
{{- if .Values.persistence.enabled }}
- name: {{ .Release.Name }}-volume
persistentVolumeClaim:
claimName: {{ .Release.Name }}-claim
{{- end }}
38 changes: 38 additions & 0 deletions incubator/puppet-forge/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "fullname" . -}}
{{- $servicePort := .Values.service.externalPort -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- if .Values.ingress.hosts }}
rules:
{{- range $host := .Values.ingress.hosts }}
- host: {{ $host.name }}
http:
paths:
- path: {{ default "/" $host.path }}
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
{{- else }}
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
16 changes: 16 additions & 0 deletions incubator/puppet-forge/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.persistence.enabled }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ .Release.Name }}-claim
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.persistence.storageclass }}
storageClassName: {{ .Values.persistence.storageclass }}
{{- end }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- end }}
19 changes: 19 additions & 0 deletions incubator/puppet-forge/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "name" . }}
release: {{ .Release.Name }}
60 changes: 60 additions & 0 deletions incubator/puppet-forge/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Default values for puppet_forge.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: hickey/puppet_forge
tag: 1.10.0
pullPolicy: IfNotPresent
service:
name: puppet-forge
type: NodePort
externalPort: 80
internalPort: 8080
ingress:
# Used to create an Ingress record.
enabled: true
hosts:
# Array of host rules
# - name: HOSTNAME
# path: URL_PATH
annotations:
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
tls:
# Secrets must be manually created in the namespace.
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources:
requests:
cpu: 100m
memory: 16Mi
limits:
cpu: 200m
memory: 32Mi

persistence:
enabled: true
size: 8Gi
## A manually managed Persistent Volume and Claim
## Requires Persistence.Enabled: true
## If defined, PVC must be created manually before volume will be bound
# ExistingClaim:

## jenkins data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageclass: "-"

puppet_forge:
url: 'https://forgeapi.puppetlabs.com/'
cache:
ttl: '1800'
size: '250'
module_dir:
- /puppet/modules

0 comments on commit ad98657

Please sign in to comment.