Skip to content

Instantly share code, notes, and snippets.

@DiederikvandenB
Last active November 29, 2018 23:36
Show Gist options
  • Save DiederikvandenB/c069ffb7e6416dc40e7ed8710a94bdd6 to your computer and use it in GitHub Desktop.
Save DiederikvandenB/c069ffb7e6416dc40e7ed8710a94bdd6 to your computer and use it in GitHub Desktop.
Micro on Kubernetes
apiVersion: v1
kind: Service
metadata:
name: micro-api
namespace: micro
labels:
name: micro-api
spec:
ports:
# the port that this service should serve on
- name: http
port: 80
targetPort: 8080
# label keys and values that must match in order to receive traffic for this service
selector:
name: micro-api
type: LoadBalancer
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: micro
name: micro-api
spec:
replicas: 1
selector:
matchLabels:
name: micro-api
template:
metadata:
labels:
name: micro-api
spec:
containers:
- name: api
env:
- name: MICRO_ENABLE_STATS
value: "true"
args:
- api
image: microhq/micro:kubernetes
imagePullPolicy: Always
ports:
- containerPort: 8080
name: api-port
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: micro
name: greeter
spec:
replicas: 1
selector:
matchLabels:
name: greeter-srv
template:
metadata:
labels:
name: greeter-srv
spec:
containers:
- name: greeter
command: [
"/greeter-srv",
"--server_name=greeter",
"--server_address=0.0.0.0:8080",
"--broker_address=0.0.0.0:10001"
]
image: microhq/greeter-srv:kubernetes
imagePullPolicy: Always
ports:
- containerPort: 8080
name: greeter-port
- name: health
command: [
"/health",
"--health_address=0.0.0.0:8081",
"--server_name=greeter",
"--server_address=0.0.0.0:8080"
]
image: microhq/health:kubernetes
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /health
port: 8081
initialDelaySeconds: 3
periodSeconds: 3
apiVersion: v1
kind: Service
metadata:
name: greeter
namespace: micro
labels:
app: greeter
spec:
ports:
- port: 8080
protocol: TCP
selector:
name: greeter-srv
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: pod-viewer-role
namespace: micro
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "patch", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: "pod-viewer-role-binding"
namespace: micro
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: "pod-viewer-role"
subjects:
- apiGroup: ""
kind: ServiceAccount
name: "default"
namespace: micro
apiVersion: v1
kind: Service
metadata:
name: micro-web
namespace: micro
labels:
name: micro-web
spec:
ports:
# the port that this service should serve on
- name: http
port: 80
targetPort: 8082
# label keys and values that must match in order to receive traffic for this service
selector:
name: micro-web
type: LoadBalancer
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: micro
name: micro-web
spec:
replicas: 1
selector:
matchLabels:
name: micro-web
template:
metadata:
labels:
name: micro-web
spec:
containers:
- name: web
env:
- name: MICRO_ENABLE_STATS
value: "true"
args:
- web
image: microhq/micro:kubernetes
imagePullPolicy: Always
ports:
- containerPort: 8082
name: web-port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment