Skip to content

Commit

Permalink
Use kind to reproduce issue sorintlab#678
Browse files Browse the repository at this point in the history
  • Loading branch information
harmjanblok committed Sep 24, 2019
1 parent cd21db4 commit fbfaf92
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.13 as builder

WORKDIR /workdir
ADD . /workdir
RUN /workdir/build


FROM alpine

COPY --from=builder /workdir/bin /bin
14 changes: 14 additions & 0 deletions test-kubernetes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env make
KUBECONFIG := $(shell kind get kubeconfig-path --name="kind")

prepare:
kind create cluster --config kind-config.yml

test:
#docker build -t sorintlab/stolon:master-pg10 ..
#kind load docker-image sorintlab/stolon:master-pg10
KUBECONFIG=$(KUBECONFIG) kubectl apply -f k8s/
#stolonctl init --cluster-name kube-stolon --store-backend kubernetes --kube-resource-kind configmap

teardown:
kind delete cluster
13 changes: 13 additions & 0 deletions test-kubernetes/k8s/role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: stolon
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: stolon
subjects:
- kind: ServiceAccount
name: default
namespace: default
22 changes: 22 additions & 0 deletions test-kubernetes/k8s/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is an example and generic rbac role definition for stolon. It could be
# fine tuned and split per component.
# The required permission per component should be:
# keeper/proxy/sentinel: update their own pod annotations
# sentinel/stolonctl: get, create, update configmaps
# sentinel/stolonctl: list components pods
# sentinel/stolonctl: get components pods annotations

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: stolon
namespace: default
rules:
- apiGroups:
- ""
resources:
- pods
- configmaps
- events
verbs:
- "*"
44 changes: 44 additions & 0 deletions test-kubernetes/k8s/stolon-sentinel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: stolon-sentinel
spec:
replicas: 2
template:
metadata:
labels:
component: stolon-sentinel
stolon-cluster: kube-stolon
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
spec:
containers:
- name: stolon-sentinel
image: sorintlab/stolon:master-pg10
command:
- "/bin/bash"
- "-ec"
- |
exec gosu stolon stolon-sentinel
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: STSENTINEL_CLUSTER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['stolon-cluster']
- name: STSENTINEL_STORE_BACKEND
value: "kubernetes"
- name: STSENTINEL_KUBE_RESOURCE_KIND
value: "configmap"
- name: STSENTINEL_METRICS_LISTEN_ADDRESS
value: "0.0.0.0:8080"
## Uncomment this to enable debug logs
#- name: STSENTINEL_DEBUG
# value: "true"
ports:
- containerPort: 8080
enableServiceLinks: false
5 changes: 5 additions & 0 deletions test-kubernetes/kind-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
image: kindest/node:v1.13.10

0 comments on commit fbfaf92

Please sign in to comment.