Skip to content

Commit

Permalink
Helm Chart Service (helm serve) (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
goruha authored and osterman committed Feb 6, 2017
1 parent b80b418 commit 09f5640
Show file tree
Hide file tree
Showing 170 changed files with 224 additions and 209 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
@@ -0,0 +1,8 @@
# Override for Makefile
[{Makefile, makefile, GNUmakefile}]
indent_style = tab
indent_size = 4

[Makefile.*]
indent_style = tab
indent_size = 4
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -38,3 +38,5 @@ Session.vim
**/requirements.lock

**/**/.values.yaml

build-harness
71 changes: 23 additions & 48 deletions .travis.yml
Expand Up @@ -6,22 +6,27 @@ addons:
- git
- make
- curl
env:
global:
- DOCKER_IMAGE_NAME=cloudposse/charts
services:
- docker

install:
- curl https://kubernetes-helm.storage.googleapis.com/helm-v2.1.3-linux-amd64.tar.gz | tar xvz
- chmod +x linux-amd64/helm
- sudo mv linux-amd64/helm /usr/bin
- helm init --client-only
- contrib/configure-dev.sh
- contrib/configure.sh
- make init
- sudo make helm:install
- make helm:repo:add-remote
- make docker:login

script:
- make clean fix-perms lint package index
- make helm:repo:build REPO_NAME=incubator
- make helm:repo:build REPO_NAME=stable
- make helm:repo:index REPO_NAME=incubator
- make helm:repo:index REPO_NAME=stable
- make docker:build

before_deploy:
- |-
rm -rf incubator/packages/Makefile &&
rm -rf stable/packages/Makefile
after_success:
- make travis:docker-tag-and-push

deploy:
# Deploy to dev (branch)
Expand All @@ -30,18 +35,8 @@ deploy:
secret_access_key: $AWS_SECRET_ACCESS_KEY
bucket: $DEV_BUCKET
skip_cleanup: true
upload-dir: $TRAVIS_BRANCH/incubator
local-dir: incubator/packages
on:
all_branches: true

- provider: s3
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
bucket: $DEV_BUCKET
skip_cleanup: true
upload-dir: $TRAVIS_BRANCH/stable
local-dir: stable/packages
upload-dir: $TRAVIS_BRANCH
local-dir: packages
on:
all_branches: true

Expand All @@ -51,18 +46,8 @@ deploy:
secret_access_key: $AWS_SECRET_ACCESS_KEY
bucket: $DEV_BUCKET
skip_cleanup: true
upload-dir: $TRAVIS_TAG/incubator
local-dir: incubator/packages
on:
tags: true

- provider: s3
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
bucket: $DEV_BUCKET
skip_cleanup: true
upload-dir: $TRAVIS_TAG/stable
local-dir: stable/packages
upload-dir: $TRAVIS_TAG
local-dir: packages
on:
tags: true

Expand All @@ -72,17 +57,7 @@ deploy:
secret_access_key: $AWS_SECRET_ACCESS_KEY
bucket: $MAIN_BUCKET
skip_cleanup: true
upload-dir: incubator
local-dir: incubator/packages
on:
branch: master

- provider: s3
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
bucket: $MAIN_BUCKET
skip_cleanup: true
upload-dir: stable
local-dir: stable/packages
upload-dir: $REPO_TYPE
local-dir: packages
on:
branch: master
branch: master
28 changes: 28 additions & 0 deletions Dockerfile
@@ -0,0 +1,28 @@
FROM alpine

ADD rootfs /

ADD ./ /charts

WORKDIR /charts

ENV CURRENT_REPO_URL=

RUN set -ex \
&& apk update \
&& apk add --no-cache \
curl \
git \
make \
bash \
&& make init \
&& make helm:install \
&& make helm:repo:add-remote \
&& make helm:repo:build REPO_NAME=incubator \
&& make helm:repo:build REPO_NAME=stable ;

EXPOSE 8879

ENTRYPOINT ["sh", "-c"]

CMD ["/init.sh"]
60 changes: 9 additions & 51 deletions Makefile
@@ -1,56 +1,14 @@
ifneq ($(TRAVIS_PULL_REQUEST_BRANCH),)
BRANCH=pr-$(TRAVIS_PULL_REQUEST_BRANCH)
else ifneq ($(TRAVIS_BRANCH),)
BRANCH=$(TRAVIS_BRANCH)
else ifneq ($(TRAVIS_TAG),)
BRANCH=$(TRAVIS_TAG)
else
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
endif
SHELL = /bin/bash
export BUILD_HARNESS_PATH ?= $(shell until [ -d "build-harness" ] || [ "`pwd`" == '/' ]; do cd ..; done; pwd)/build-harness
-include $(BUILD_HARNESS_PATH)/Makefile

ifeq ($(BRANCH),master)
export REPO_URL ?= https://charts.cloudposse.com
else
export REPO_URL ?= https://charts.dev.cloudposse.com/$(BRANCH)
endif

all: package index

.PHONY : fix-perms
## Fix filesystem permissions
fix-perms:
@find . -type f -name '*.yaml' -exec chmod 644 {} \;
@find . -type f -name '*.txt' -exec chmod 644 {} \;
@find . -type f -name '*.tpl' -exec chmod 644 {} \;
@find . -type f -name '*.md' -exec chmod 644 {} \;
@find . -type f -name '*.tgz' -exec chmod 644 {} \;

.PHONY : info
## Show information about each repo
info:
@make -C stable $@
@make -C incubator $@

.PHONY : package
## Generate packages of all charts
package:
@make -C stable $@
@make -C incubator $@

.PHONY : index
## Index all packages
index:
@make -C stable $@
@make -C incubator $@
.PHONY : init
## Init build-harness
init:
@curl --retry 5 --retry-delay 1 https://raw.githubusercontent.com/cloudposse/build-harness/master/bin/install.sh | bash

.PHONY : clean
## Clean up
## Clean build-harness
clean:
@make -C stable $@
@make -C incubator $@
@rm -rf $(BUILD_HARNESS_PATH)

.PHONY : lint
## Lint
lint:
@make -C stable/library $@
@make -C incubator/library $@
9 changes: 0 additions & 9 deletions Makefile.library

This file was deleted.

16 changes: 0 additions & 16 deletions Makefile.packages

This file was deleted.

24 changes: 0 additions & 24 deletions Makefile.repo

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -6,4 +6,5 @@ Just run `make` to generate all packages and corresponding repository indexes.

## Configuring Helm

Just run `contrib/configure.sh`
Just run `make init && make helm:repo:add-remote`

30 changes: 0 additions & 30 deletions contrib/configure-dev.sh

This file was deleted.

20 changes: 0 additions & 20 deletions contrib/configure.sh

This file was deleted.

1 change: 0 additions & 1 deletion incubator/Makefile

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions incubator/helm-serve/Chart.yaml
@@ -0,0 +1,4 @@
apiVersion: v1
description: A Helm chart that implements the `helm serve` repository server for Helm on Kubernetes
name: helm-serve
version: 0.1.0
24 changes: 24 additions & 0 deletions incubator/helm-serve/templates/NOTES.txt
@@ -0,0 +1,24 @@
1. Get the application URL by running these commands:
{{- 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/login
{{- 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 "fullname" . }}" -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 }}

To install helm charts run

helm repo add {{ template "fullname" . }}-incubator {{ template "server_url" . }}/incubator
helm repo add {{ template "fullname" . }}-stable {{ template "server_url" . }}/stable

helm install {{ template "fullname" . }}-incubator/{CHART NAME}

WARNING: Be sure that {{ template "server_url" . }} resolves correctly from place you want to install helm
33 changes: 33 additions & 0 deletions incubator/helm-serve/templates/_helpers.tpl
@@ -0,0 +1,33 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 24 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 24 | trimSuffix "-" -}}
{{- end -}}


{{/*
Create a default fully qualified app name.
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "server_url" -}}
{{- if empty .Values.url -}}
{{- if .Values.service.externalPort | quote | eq "443" }}
https://{{ template "fullname" . }}.{{ .Release.Namespace }}
{{- else -}}
http://{{ template "fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.externalPort }}
{{- end -}}
{{- else -}}
{{ .Values.url }}
{{- end -}}
{{- end -}}

0 comments on commit 09f5640

Please sign in to comment.