Added deployment stuffs

This commit is contained in:
DutchEllie 2022-05-29 18:39:53 +02:00
parent fc8d73468d
commit 99e7c01145
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:UU8yhd1Bh8exU88ev0ej/Dm+CeyfR/ZIDRrpRfYdfbg
9 changed files with 179 additions and 0 deletions

52
.drone.yml Normal file
View File

@ -0,0 +1,52 @@
kind: pipeline
type: kubernetes
name: default
trigger:
event:
- push
steps:
- name: build
image: golang:1.18.0-alpine
volumes:
- name: builder
path: /drone/src/build
commands:
- go build -o ./build/app ./src
- name: docker
image: plugins/docker
volumes:
- name: builder
path: /drone/src/build
settings:
cache_from:
- "dutchellie/proper-website-p2p-api:latest"
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: dutchellie/proper-website-p2p-api
tags:
- latest
- ${DRONE_COMMIT_SHA:0:8}
- name: deploy
image: pelotech/drone-helm3
settings:
mode: upgrade
chart: .drone/helm/api
namespace: drone-production
release: quenten-p2p-api-prod
skip_tls_verify: true
values_files:
- .drone/helm/prod-val.yaml
values:
- "image.image=dutchellie/proper-website-p2p-api:${DRONE_COMMIT_SHA:0:8}"
kube_api_server:
from_secret: prod_api_server
kube_token:
from_secret: prod_kube_token
kube_certificate:
from_secret: prod_kube_certificate
kube_service_account: drone-deploy
dry_run: false

View File

@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@ -0,0 +1,5 @@
apiVersion: v2
name: p2p-api
description: Helm chart for p2p API
type: application
version: 0.0.1

View File

@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
namespace: {{ .Release.Namespace }}
{{- if .Values.annotations }}
annotations: {{ toYaml .Values.annotations | nindent 4}}
{{- end}}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Values.name }}
release: {{ .Values.release }}
template:
metadata:
{{- if .Values.podAnnotations }}
annotations:
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
labels:
app: {{ .Values.name }}
release: {{ .Values.release }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Values.containerName }}
image: {{ .Values.image.image }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: p2papi
protocol: TCP
containerPort: 6666
- name: p2papi
protocol: UDP
containerPort: 6666
# env:
# - name: MONGO_CREDS
# value: {{ .Values.mongoCreds }}

View File

@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
app: {{ .Values.name }}
release: {{ .Values.release }}
ports:
- protocol: TCP
name: p2papi
port: 6666
targetPort: 6666
- protocol: UDP
name: p2papi
port: 6666
targetPort: 6666

View File

@ -0,0 +1,15 @@
name: p2papi-deployment
annotations: {}
replicaCount: 1
release: latest
podAnnotations: {}
imagePullSecrets: {}
containerName: proper-website-p2p-api
image:
image: dutchellie/proper-website-p2p-api
pullPolicy: Always
service:
name: p2papi-service
annotations: {}

View File

@ -0,0 +1,7 @@
name: p2papi-prod
image:
pullPolicy: Always
service:
name: p2papi-prod

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root
RUN ./build/app .
EXPOSE 6666
CMD ["./app"]

5
src/main.go Normal file
View File

@ -0,0 +1,5 @@
package main
func main() {
}