Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #858 from dexhorthy/helm-values
Browse files Browse the repository at this point in the history
make helmValues work in non init-chart workflows
  • Loading branch information
dexhorthy authored Mar 12, 2019
2 parents 48cb8e9 + f66cc27 commit 3ed9393
Show file tree
Hide file tree
Showing 39 changed files with 1,726 additions and 7 deletions.
35 changes: 35 additions & 0 deletions fixtures/sv-helm-values/ship.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
assets:
v1: []

config: {}

lifecycle:
v1:
- render:
root: ./
assets:
v1:
- github:
dest: ./installer/consul
repo: helm/charts
path: stable/consul
ref: master
strip_path: true
- helmValues:
path: installer/consul/values.yaml
- render:
root: ./
assets:
v1:
- helm:
dest: ./installer/base
local:
chart_root: ./installer/consul
values_from:
# haaaack, helmValues needs a configurable dest path for us to store the output
path: .ship/tmp
- kustomize:
base: installer/base
dest: installer/rendered.yaml

16 changes: 15 additions & 1 deletion hack/docs/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,21 @@
"required": []
}
},
{
"path": "properties.lifecycle.properties.v1.items.properties.helmValues",
"merge": {
"description": "A `helmValues` step displays an editor for the end user to configure helm values. The rendered values are available at `.ship/tmp/values.yaml`",
"examples": [
{},
{
"path": "subcharts/consul/values.yaml"
}
]
},
"replace": {
"required": []
}
},
{
"path": "properties.lifecycle.properties.v1.items.properties.terraform",
"merge": {
Expand Down Expand Up @@ -1239,7 +1254,6 @@
"path": "properties.lifecycle.properties.v1.items.properties",
"delete": [
"helmIntro",
"helmValues",
"kubectlApply.properties.StepShared",
"unfork"
]
Expand Down
34 changes: 34 additions & 0 deletions hack/docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,40 @@
},
"required": []
},
"helmValues": {
"description": "A `helmValues` step displays an editor for the end user to configure helm values. The rendered values are available at `.ship/tmp/values.yaml`",
"examples": [
{},
{
"path": "subcharts/consul/values.yaml"
}
],
"type": "object",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"invalidates": {
"type": "array",
"items": {
"type": "string"
}
},
"path": {
"type": "string"
},
"requires": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": []
},
"kubectlApply": {
"description": "A `kubectlApply` step will run `kubectl apply` with the provided file path and kubeconfig.",
"examples": [
Expand Down
36 changes: 36 additions & 0 deletions integration/base/shipapp-helm-values/expected/.ship/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
assets:
v1: []

config: {}

lifecycle:
v1:
- render:
root: ./
assets:
v1:
- github:
dest: ./installer/consul
repo: helm/charts
path: stable/consul
ref: master
strip_path: true
- helmValues:
path: installer/consul/values.yaml
- render:
root: ./
assets:
v1:
- helm:
dest: ./installer/base
local:
chart_root: ./installer/consul
values_from:
# haaaack, helmValues still needs a configurable dest path for us to store the output
path: .ship/tmp
- kustomize:
base: installer/base
dest: installer/consul-rendered.yaml


14 changes: 14 additions & 0 deletions integration/base/shipapp-helm-values/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"v1": {
"config": {},
"helmValues": "# Default values for consul.\n# This is a YAML-formatted file.\n# Declare name/value pairs to be passed into your templates.\n# name: value\n\n## Consul service ports\nHttpPort: 8500\nRpcPort: 8400\nSerflanPort: 8301\nSerflanUdpPort: 8301\nSerfwanPort: 8302\nSerfwanUdpPort: 8302\nServerPort: 8300\nConsulDnsPort: 8600\n\n## Specify the domain with which consul should run with\n## This will be passed as a -domain parameter\nDomain: consul\n\n## Used as selector\nComponent: \"consul\"\nReplicas: 3\nImage: \"consul\"\nImageTag: \"1.0.0\"\nImagePullPolicy: \"Always\"\nResources: {}\n # requests:\n # cpu: \"100m\"\n # memory: \"256Mi\"\n # limits:\n # cpu: \"500m\"\n # memory: \"512Mi\"\n## Persistent volume size\n\npriorityClassName: \"\"\n\nStorage: \"1Gi\"\n\n## Needed for 0.8.0 and later IF all consul containers are spun up\n## on the same machine. Without this they all generate the same\n## host id.\nDisableHostNodeId: false\n\n## Datacenter name for consul. If not supplied, will use the consul\n## default 'dc1'\n# DatacenterName: dc1\n\n## Encrypt Gossip Traffic\nGossip:\n Encrypt: true\n Create: true\n\n## predefined value for gossip key.\n## Will use a generated random alpha numeric if not provided\n# GossipKey: key\n\n## consul data Persistent Volume Storage Class\n## If defined, StorageClassName: \u003cstorageClass\u003e\n## If set to \"-\", StorageClassName: \"\", which disables dynamic provisioning\n## If undefined (the default) or set to null, no storageClassName spec is\n## set, choosing the default provisioner. (gp2 on AWS, standard on\n## GKE, AWS \u0026 OpenStack)\n##\n# StorageClass: \"-\"\n\n## Setting maxUnavailable will create a pod disruption budget that will prevent\n## voluntarty cluster administration from taking down too many consul pods. If\n## you set maxUnavailable, you should set it to ceil((n/2) - 1), where\n## n = Replicas. For example, if you have 5 or 6 Replicas, you'll want to set\n## maxUnavailable = 2. If you are using the default of 3 Replicas, you'll want\n## to set maxUnavailable to 1.\nmaxUnavailable: 1\n\n## nodeAffinity settings\n# nodeAffinity:\n# requiredDuringSchedulingIgnoredDuringExecution:\n# nodeSelectorTerms:\n# - matchExpressions:\n# - key: cloud.google.com/gke-preemptible\n# operator: NotIn\n# values:\n# - true\n\n## Affinity settings\naffinity: |\n podAntiAffinity:\n preferredDuringSchedulingIgnoredDuringExecution:\n - weight: 1\n podAffinityTerm:\n topologyKey: kubernetes.io/hostname\n labelSelector:\n matchExpressions:\n - key: component\n operator: In\n values:\n - \"{{ .Release.Name }}-{{ .Values.Component }}\"\n\n## Enable Consul Web UI\n##\nui:\n enabled: true\n## Create dedicated UI service\n##\nuiService:\n enabled: true\n type: \"NodePort\"\n annotations: {}\n\nConsulConfig: []\n# - type: secret\n# name: consul-defaults\n# - type: configMap\n# name: consul-defaults\n\n## Create an Ingress for the Web UI\nuiIngress:\n enabled: false\n annotations: {}\n labels: {}\n hosts: []\n tls: {}\n\n## Useful when ACLs are enabled\nacl:\n enabled: false\n masterToken: \"\"\n agentToken: \"\"\n\n## test container details\ntest:\n image: lachlanevenson/k8s-kubectl\n imageTag: v1.4.8-bash\n rbac:\n create: false\n serviceAccountName: \"\"\n\nnodeSelector: {}\ntolerations: []\n",
"releaseName": "ship",
"upstream": "__upstream__",
"metadata": {
"applicationType": "replicated.app",
"releaseNotes": "",
"version": ""
},
"contentSHA": "c5867ba390c3096bb50236089be2b72a7658837a4d9976fb9db54c03575cbd61"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
labels:
component: ship-consul
release: ship
name: ship-consul
spec:
clusterIP: None
ports:
- name: http
port: 8500
- name: rpc
port: 8400
- name: serflan-tcp
port: 8301
protocol: TCP
- name: serflan-udp
port: 8301
protocol: UDP
- name: serfwan-tcp
port: 8302
protocol: TCP
- name: serfwan-udp
port: 8302
protocol: UDP
- name: server
port: 8300
- name: consuldns-tcp
port: 8600
- name: consuldns-udp
port: 8600
protocol: UDP
selector:
component: ship-consul
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
labels:
component: ship-consul
release: ship
name: ship-consul
spec:
replicas: 3
selector:
matchLabels:
component: ship-consul
release: ship
serviceName: ship-consul
template:
metadata:
labels:
chart: consul-3.5.3
component: ship-consul
heritage: Tiller
release: ship
name: ship-consul
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: component
operator: In
values:
- ship-consul
topologyKey: kubernetes.io/hostname
weight: 1
containers:
- command:
- /bin/sh
- -ec
- |
IP=$(hostname -i)
if [ -e /etc/consul/secrets/gossip-key ]; then
echo "{\"encrypt\": \"$(base64 /etc/consul/secrets/gossip-key)\"}" > /etc/consul/encrypt.json
GOSSIP_KEY="-config-file /etc/consul/encrypt.json"
fi
for i in $(seq 0 $((${INITIAL_CLUSTER_SIZE} - 1))); do
while true; do
echo "Waiting for ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME} to come up"
ping -W 1 -c 1 ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME}.${STATEFULSET_NAMESPACE}.svc > /dev/null && break
sleep 1s
done
done
PEERS=""
for i in $(seq 0 $((${INITIAL_CLUSTER_SIZE} - 1))); do
NEXT_PEER="$(ping -c 1 ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME}.${STATEFULSET_NAMESPACE}.svc | awk -F'[()]' '/PING/{print $2}')"
if [ "${NEXT_PEER}" != "${POD_IP}" ]; then
PEERS="${PEERS}${PEERS:+ } -retry-join ${STATEFULSET_NAME}-${i}.${STATEFULSET_NAME}.${STATEFULSET_NAMESPACE}.svc"
fi
done
exec /bin/consul agent \
-ui \
-domain=consul \
-data-dir=/var/lib/consul \
-server \
-bootstrap-expect=${INITIAL_CLUSTER_SIZE} \
-disable-keyring-file \
-bind=0.0.0.0 \
-advertise=${IP} \
${PEERS} \
${GOSSIP_KEY} \
-client=0.0.0.0 \
-dns-port=${DNSPORT} \
-http-port=8500
env:
- name: INITIAL_CLUSTER_SIZE
value: "3"
- name: STATEFULSET_NAME
value: ship-consul
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: STATEFULSET_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: DNSPORT
value: "8600"
image: consul:1.0.0
imagePullPolicy: Always
livenessProbe:
exec:
command:
- consul
- members
- -http-addr=http://127.0.0.1:8500
initialDelaySeconds: 300
timeoutSeconds: 5
name: ship-consul
ports:
- containerPort: 8500
name: http
- containerPort: 8400
name: rpc
- containerPort: 8301
name: serflan-tcp
protocol: TCP
- containerPort: 8301
name: serflan-udp
protocol: UDP
- containerPort: 8302
name: serfwan-tcp
protocol: TCP
- containerPort: 8302
name: serfwan-udp
protocol: UDP
- containerPort: 8300
name: server
- containerPort: 8600
name: consuldns-tcp
- containerPort: 8600
name: consuldns-udp
protocol: UDP
resources: {}
volumeMounts:
- mountPath: /var/lib/consul
name: datadir
- mountPath: /etc/consul/secrets
name: gossip-key
readOnly: true
securityContext:
fsGroup: 1000
volumes:
- name: gossip-key
secret:
secretName: ship-consul-gossip-key
updateStrategy:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: v1
kind: Pod
metadata:
annotations:
helm.sh/hook: test-success
name: ship-ui-test-ol3of
spec:
containers:
- command:
- /tools/bats/bats
- -t
- /tests/run.sh
image: lachlanevenson/k8s-kubectl:v1.4.8-bash
name: ship-ui-test
volumeMounts:
- mountPath: /tests
name: tests
readOnly: true
- mountPath: /tools
name: tools
initContainers:
- command:
- bash
- -c
- |
set -ex
# copy bats to tools dir
cp -R /usr/local/libexec/ /tools/bats/
image: dduportal/bats:0.4.0
name: test-framework
volumeMounts:
- mountPath: /tools
name: tools
restartPolicy: Never
volumes:
- configMap:
name: ship-consul-tests
name: tests
- emptyDir: {}
name: tools
Loading

0 comments on commit 3ed9393

Please sign in to comment.