This repository was archived by the owner on Mar 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make helmValues work in non init-chart workflows
What I Did ------------ I made HelmValues work in non init-chart workflows. full POC (also in integration test): ```yaml --- 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 ``` How I Did it ------------ - add path field to `daemontypes.Step.HelmValues`, copy it over from existing `api.Step.HelmValues` - read this `HelmValues.Path` field in `GET /navcycle/step/helm-values` and the `POST /helm-values`, falling back to the old way of `.ship/tmp/values.yaml` - When linting chart, use `filepath.Dir(step.HelmValues.path)` as the base directory for linting, defaulting to the old `.ship/tmp/chart` - tried to remove constants/global-state-in-the-filesystem where possible How to verify it ------------ - `ship init` the ship.yml in [integration/base/shipapp-helm-values/input/.ship/ship.yaml](integration/base/shipapp-helm-values/input/.ship/ship.yaml) - touched some newer unfork code that I'm not as familiar with--still need to test unfork Description for the Changelog ------------ Make some changes around path handling that allow a `lifecycle.v1.helmValues` step to be used outside of the core `ship init <chart>` workflow. 
- Loading branch information
Showing
39 changed files
with
1,726 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
integration/base/shipapp-helm-values/expected/.ship/release.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
integration/base/shipapp-helm-values/expected/.ship/state.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
integration/base/shipapp-helm-values/expected/installer/base/consul-service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
150 changes: 150 additions & 0 deletions
150
integration/base/shipapp-helm-values/expected/installer/base/consul-statefulset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
40 changes: 40 additions & 0 deletions
40
integration/base/shipapp-helm-values/expected/installer/base/consul-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.