Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
workspace:
base: /go
path: src/github.com/src-d/code-annotation

branches: [master, staging, release/*]

pipeline:

clone:
image: plugins/git
debug: true


# build on pull requests

build:
image: golang:1.8-alpine3.6
environment:
- REACT_APP_SERVER_URL="//code-annotation.sourced.tech"
commands:
- apk --update upgrade
- apk add --no-cache make git curl ca-certificates bash build-base libxml2-dev protobuf nodejs=6.10.3-r1 nodejs-npm
- npm install -g yarn
- make build
- make packages
debug: true
when:
event: [pull_request]


# deployment to staging environment

build_stg:
image: golang:1.8-alpine3.6
environment:
- REACT_APP_SERVER_URL="//code-annotation-staging.srcd.run"
commands:
- apk --update upgrade
- apk add --no-cache make git curl ca-certificates bash build-base libxml2-dev protobuf nodejs=6.10.3-r1 nodejs-npm
- npm install -g yarn
- make build
- make packages
debug: true
when:
branch: [staging]
event: [push]

docker_stg:
group: docker
image: plugins/docker
registry: docker.io
repo: srcd/code-annotation
secrets: [ docker_username, docker_password ]
# workaround for bug https://github.com/kubernetes/helm/issues/1707
tag: 'commit-${DRONE_COMMIT_SHA:0:7}'
dockerfile: Dockerfile
debug: true
when:
branch: [staging]
event: [push]

helm_deploy_stg:
image: quay.io/ipedrazas/drone-helm
skip_tls_verify: true
chart: ./helm-charts/code-annotation
release: code-annotation
prefix: STG
secrets: [ STG_API_SERVER, STG_KUBERNETES_TOKEN ]
values: ingress.globalStaticIpName=code-annotation-staging,ingress.hostname=code-annotation-staging.srcd.run,image.tag=commit-${DRONE_COMMIT_SHA:0:7}
tiller_ns: kube-system
wait: true
when:
branch: [staging]
event: [push]
21 changes: 21 additions & 0 deletions helm-charts/code-annotation/.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
4 changes: 4 additions & 0 deletions helm-charts/code-annotation/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: code-annotation
version: 0.0.1
53 changes: 53 additions & 0 deletions helm-charts/code-annotation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Code Annotation Tool

This chart deploys source{d} [code annotation tool](https://github.com/src-d/code-annotation)

## Pre-requisites

* Kubernetes 1.4+ with Beta APIs enabled

## Installing the chart

All parameters under `settings` in [values.yaml](values.yaml) must be provided.

```
helm install -n <release-name> <chart path> --set \
secrets.jwt_signing_key=<signing-key>,\
secrets.github_client=<client-id>,\
secrets.github_secret=<client-secret>,\
ingress.hostname=<hostname>,\
ingress.globalStaticIpName=<static-ip>,\
image.tag=<your-favourite.tag>
```

These are the mandatory parameters that need to be provided or installation will fail.
Other parameters can be provided too but, if not, a default value will be used.

It's also possible to set name of separately deployed secrets using parameter `secretName`.

Full command for deployment:

```
helm install -n <release-name> <chart path> --set \
secretName=<name-of-secret-object>,\
ingress.hostname=<hostname>,\
ingress.globalStaticIpName=<static-ip>,\
image.tag=<your-favourite.tag>
```

# Configuration

Please refer to [values.yaml](values.yaml) for the full run-down on defaults.

To override any of those default values,
specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

Alternatively, a YAML file that specifies the values for the parameters can be provided
while installing the chart.
For example,

```bash
$ helm install --name <release-name> -f values.yaml <path-to-chart>
```

> **Tip**: You can use the default [values.yaml](values.yaml)
16 changes: 16 additions & 0 deletions helm-charts/code-annotation/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 -}}
57 changes: 57 additions & 0 deletions helm-charts/code-annotation/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- $secretName := default (include "fullname" .) .Values.secretName -}}

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:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ required "Image tag is required" .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: UI_DOMAIN
value: "//{{ .Values.ingress.hostname }}"
- name: OAUTH_CLIENT_ID
valueFrom:
secretKeyRef:
name: {{ $secretName }}
key: github_client
- name: OAUTH_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: {{ $secretName }}
key: github_secret
- name: JWT_SIGNING_KEY
valueFrom:
secretKeyRef:
name: {{ $secretName }}
key: jwt_signing_key
ports:
- containerPort: {{ .Values.service.codeAnnotation.internalPort }}
livenessProbe:
httpGet:
path: /
port: {{ .Values.service.codeAnnotation.internalPort }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.service.codeAnnotation.internalPort }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
33 changes: 33 additions & 0 deletions helm-charts/code-annotation/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- $serviceName := include "fullname" . -}}
{{- $servicePort := .Values.service.codeAnnotation.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 }}
stable.k8s.psg.io/kcm.class: {{ .Values.ingress.kcmClass }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
kubernetes.io/ingress.global-static-ip-name: {{ required "Missing .Values.ingress.globalStaticIpName" .Values.ingress.globalStaticIpName }}
spec:
rules:
- host: {{ required "Hostname is missing" .Values.ingress.hostname }}
http:
paths:
- path: /*
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}

{{- if .Values.ingress.tls }}
tls:
- secretName: "{{ template "fullname" . }}-tls"
hosts:
- {{ .Values.ingress.hostname }}
{{- end }}
18 changes: 18 additions & 0 deletions helm-charts/code-annotation/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# create secrets only if there is no name for existing secrets
{{- required "Secrets or secretName are missing" (or .Values.secretName .Values.secrets) }}
{{- if not .Values.secretName }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: Opaque
data:
github_client: "{{ required "Github client ID is missing" .Values.secrets.github_client | b64enc }}"
github_secret: "{{ required "Github secret is missing" .Values.secrets.github_secret | b64enc }}"
jwt_signing_key: "{{ required "JWT signing key secret is missing" .Values.secrets.jwt_signing_key | b64enc }}"
{{- end }}
19 changes: 19 additions & 0 deletions helm-charts/code-annotation/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.codeAnnotation.externalPort }}
targetPort: {{ .Values.service.codeAnnotation.internalPort }}
protocol: TCP
name: {{ .Values.service.codeAnnotation.name }}
selector:
app: {{ template "name" . }}
release: {{ .Release.Name }}
46 changes: 46 additions & 0 deletions helm-charts/code-annotation/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Default values for landing.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1

# If provided, these will be used by the deployment
# nodeSelector: XXXXXXX

image:
repository: docker.io/srcd/code-annotation
# tag must be received as a parameter
pullPolicy: IfNotPresent
service:
type: NodePort
codeAnnotation:
externalPort: 8080
internalPort: 8080
name: code-annotation
ingress:
kcmClass: default
annotations:
kubernetes.io/ingress.class: gce
tls: true
# below values are required
# hostname: "code-annotation-staging.srcd.run"
# globalStaticIpName: "code-annotation-ip"

# Provide with 'helm install', and do NOT change it when doing 'helm upgrade'
# github_client:
# github_secret:
# jwt_signing_key:
# It's also possible to use deployed secrets by using argument:
# secretName: "existing name"

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
#requests:
# cpu: 100m
# memory: 128Mi
#