Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
Last active May 7, 2022 13:17
Show Gist options
  • Save kevinswiber/e6f36e7ac283a012a76372057bc52a8e to your computer and use it in GitHub Desktop.
Save kevinswiber/e6f36e7ac283a012a76372057bc52a8e to your computer and use it in GitHub Desktop.
Files for Running Express Gateway in Kubernetes, Part 2
apiVersion: v1
kind: ConfigMap
metadata:
name: 'express-gateway-config'
data:
gateway.config.yml: |
http:
host: '*'
port: 8080
admin:
host: '0.0.0.0'
port: 9876
apiEndpoints:
api:
host: '*'
paths: '/ip'
serviceEndpoints:
httpbin:
url: 'http://httpbin' # Uses kube-dns for Service Discovery.
policies:
- proxy
pipelines:
- name: default
apiEndpoints:
- api
policies:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
system.config.yml: |
# When running in production, you may want to use a real instance of Redis.
# If so, it's recommended to use an environment varible for your password.
# You can pull this password from a Secret in Kubernetes and wire it up to
# the Deployment.
db:
redis:
emulate: true
namespace: EG-
crypto:
cipherKey: sensitiveKey
algorithm: aes256
saltRounds: 10
session:
secret: keyboard cat
resave: false
saveUninitialized: false
accessTokens:
timeToExpiry: 7200000
refreshTokens:
timeToExpiry: 7200000
authorizationCodes:
timeToExpiry: 7200000
apiVersion: apps/v1beta2 # for Kubernetes v1.9.x, use apps/v1
kind: Deployment
metadata:
name: express-gateway
labels:
app: express-gateway
spec:
selector:
matchLabels:
app: express-gateway
template:
metadata:
labels:
app: express-gateway
spec:
volumes:
- name: config
configMap:
name: express-gateway-config
containers:
- name: express-gateway
image: expressgateway/express-gateway:latest
imagePullPolicy: Always
env:
- name: EG_CONFIG_DIR
value: '/usr/src/app/config'
- name: LOG_LEVEL
value: debug
ports:
- name: gateway
containerPort: 8080
- name: admin
containerPort: 9876
volumeMounts:
- name: config
mountPath: '/usr/src/app/config/system.config.yml'
subPath: 'system.config.yml'
- name: config
mountPath: '/usr/src/app/config/gateway.config.yml'
subPath: 'gateway.config.yml'
apiVersion: v1
kind: Service
metadata:
name: express-gateway-service
spec:
selector:
app: express-gateway
type: NodePort
ports:
- name: 'gateway'
port: 80
targetPort: 'gateway'
nodePort: 31313
protocol: TCP
- name: 'admin'
port: 9876
targetPort: 'admin'
nodePort: 31314
protocol: TCP
---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: httpbin
spec:
replicas: 1
selector:
matchLabels:
app: httpbin
template:
metadata:
labels:
app: httpbin
version: v1
spec:
containers:
- image: docker.io/citizenstig/httpbin
imagePullPolicy: IfNotPresent
name: httpbin
ports:
- containerPort: 8000
---
apiVersion: v1
kind: Service
metadata:
name: httpbin
labels:
app: httpbin
spec:
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8000
selector:
app: httpbin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment