-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development & software operations: kite service, Dockerfile, charts, …
…pipeline, Helm & other stuff.
- Loading branch information
Yaroslav Savchuk
committed
Jan 10, 2018
1 parent
8a5343c
commit bd7e3c9
Showing
21 changed files
with
771 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
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,48 @@ | ||
FROM ruby:2.5.0 | ||
|
||
# By default image is built using RAILS_ENV=production. | ||
# You may want to customize it: | ||
# | ||
# --build-arg RAILS_ENV=development | ||
# | ||
# See https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables-build-arg | ||
# | ||
ARG RAILS_ENV=production | ||
ENV RAILS_ENV ${RAILS_ENV} | ||
|
||
ENV APP_HOME=/home/app | ||
|
||
RUN groupadd -r app --gid=1000 | ||
RUN useradd -r -m -g app -d /home/app --uid=1000 app | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
default-libmysqlclient-dev\ | ||
imagemagick | ||
|
||
WORKDIR $APP_HOME | ||
|
||
COPY Gemfile Gemfile.lock $APP_HOME/ | ||
|
||
# Install dependencies | ||
RUN mkdir -p /opt/vendor/bundle && chown -R app:app /opt/vendor | ||
RUN su app -s /bin/bash -c "bundle install --path /opt/vendor/bundle" | ||
|
||
# Copy the main application. | ||
COPY . $APP_HOME | ||
|
||
RUN chown -R app:app /home/app && \ | ||
mv config/database.yml.example config/database.yml | ||
USER app | ||
|
||
RUN bundle exec rake tmp:create assets:precompile | ||
|
||
# Expose port 8080 to the Docker host, so we can access it | ||
# from the outside. | ||
EXPOSE 8080 | ||
ENTRYPOINT ["bundle", "exec"] | ||
|
||
# The main command to run when the container starts. Also | ||
# tell the Rails dev server to bind to all interfaces by | ||
# default. | ||
CMD ["rails", "s", "-p", "8080", "-b", "0.0.0.0"] |
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 |
---|---|---|
|
@@ -230,4 +230,4 @@ DEPENDENCIES | |
uglifier (~> 4) | ||
|
||
BUNDLED WITH | ||
1.16.1 | ||
1.16.0 |
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,28 @@ | ||
VERSION ?= $(shell cat VERSION) | ||
ENV ?= staging | ||
SERVICE := barong | ||
IMAGE := gcr.io/helios-stage/barong:$(VERSION) | ||
CURRENT_CONTEXT := $(shell kubectl config current-context) | ||
|
||
.PHONY: default build push run ci deploy | ||
|
||
default: build run | ||
|
||
build: | ||
@echo '> Using ENV: $(ENV) and context: $(CURRENT_CONTEXT)' | ||
@echo '> Building "$(SERVICE)" docker image...' | ||
@docker build -t $(IMAGE) . | ||
|
||
push: build | ||
gcloud docker -- push $(IMAGE) | ||
|
||
run: | ||
@echo '> Starting "$(SERVICE)" container...' | ||
@docker run -d $(IMAGE) | ||
|
||
ci: | ||
@fly -t ci set-pipeline -p $(SERVICE) -c config/pipelines/review.yml -n | ||
@fly -t ci unpause-pipeline -p $(SERVICE) | ||
|
||
deploy: | ||
@helm install ./config/charts/$(SERVICE) --set "image.tag=$(VERSION)" |
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 @@ | ||
0.1.0 |
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,4 @@ | ||
apiVersion: v1 | ||
description: A Barong chart | ||
name: barong | ||
version: 0.1.0 |
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,19 @@ | ||
1. Get the application URL by running these commands: | ||
{{- if .Values.ingress.enabled }} | ||
{{- range .Values.ingress.hosts }} | ||
http://{{ . }} | ||
{{- 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.internalPort }} | ||
{{- end }} |
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,82 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
|
||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Expands image name. | ||
*/}} | ||
{{- define "image" -}} | ||
{{- printf "%s:%s" .Values.image.repository .Values.image.tag -}} | ||
{{- 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 -}} | ||
|
||
{{/* | ||
Environment for database migration job. | ||
It is pre-install hook, so we don't have secrets created yet and we need to use plain password. | ||
*/}} | ||
{{- define "prepare-db-env" -}} | ||
- name: RAILS_ENV | ||
value: production | ||
- name: DATABASE_HOST | ||
value: {{ .Values.db.host }} | ||
- name: DATABASE_USER | ||
value: {{ default "root" .Values.db.user }} | ||
- name: COOKIES_SECRET_KEY | ||
value: "" | ||
{{- if .Values.db.password }} | ||
- name: DATABASE_PASSWORD | ||
value: {{ .Values.db.password }} | ||
{{- end }} | ||
{{- end -}} | ||
{{/* | ||
Environment for barong container | ||
*/}} | ||
{{- define "env" -}} | ||
{{- range $key, $value := .Values.barong.env }} | ||
- name: {{ $key }} | ||
value: {{ $value | quote }} | ||
{{- end }} | ||
- name: RAILS_ENV | ||
value: production | ||
- name: URL_HOST | ||
value: {{ .Values.ingress.host }} | ||
- name: URL_SCHEME | ||
value: http{{ if .Values.ingress.tls }}s{{ end }} | ||
- name: DATABASE_HOST | ||
value: {{ .Values.db.host }} | ||
- name: DATABASE_USER | ||
value: {{ default "root" .Values.db.user }} | ||
- name: SECRET_KEY_BASE | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ template "fullname" . }} | ||
key: cookiesSecretKey | ||
{{- if .Values.db.password }} | ||
- name: DATABASE_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ template "fullname" . }} | ||
key: dbPassword | ||
{{- end }} | ||
{{- if .Values.db.name }} | ||
- name: DATABASE_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ template "fullname" . }} | ||
key: dbName | ||
{{- end }} | ||
{{- end -}} |
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: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
app: {{ template "name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ template "name" . }} | ||
release: {{ .Release.Name }} | ||
spec: | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
image: {{ template "image" . }} | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
- containerPort: {{ .Values.service.internalPort }} | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: {{ .Values.service.internalPort }} | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: {{ .Values.service.internalPort }} | ||
resources: | ||
{{ toYaml .Values.resources | indent 12 }} | ||
{{- if .Values.nodeSelector }} | ||
nodeSelector: | ||
{{ toYaml .Values.nodeSelector | indent 8 }} | ||
{{- end }} |
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 @@ | ||
{{- 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 }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
annotations: | ||
{{- range $key, $value := .Values.ingress.annotations }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
spec: | ||
rules: | ||
{{- range $host := .Values.ingress.hosts }} | ||
- host: {{ $host }} | ||
http: | ||
paths: | ||
- path: / | ||
backend: | ||
serviceName: {{ $serviceName }} | ||
servicePort: {{ $servicePort }} | ||
{{- end -}} | ||
{{- if .Values.ingress.tls }} | ||
tls: | ||
{{- range $host := .Values.ingress.hosts }} | ||
- secretName: {{ $host | replace "." "-" }}-barong-tls | ||
hosts: | ||
- {{ $host }} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} |
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,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
app: {{ template "name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
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 }} |
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,29 @@ | ||
# Default values for barong. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
replicaCount: 1 | ||
image: | ||
repository: gcr.io/helios-stage/barong | ||
tag: 0.1.0 | ||
pullPolicy: IfNotPresent | ||
service: | ||
name: barong | ||
type: ClusterIP | ||
externalPort: 8080 | ||
internalPort: 8080 | ||
ingress: | ||
enabled: true | ||
hosts: | ||
- barong.local | ||
annotations: | ||
kubernetes.io/ingress.class: nginx | ||
kubernetes.io/tls-acme: "true" | ||
tls: | ||
enabled: true | ||
|
||
resources: {} | ||
|
||
barong: | ||
env: {} | ||
|
||
db: {} |
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
Empty file.
Oops, something went wrong.