Skip to content

Instantly share code, notes, and snippets.

@samolabams
Forked from kevinswiber/1-install.sh
Created January 9, 2020 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samolabams/9cbe78934edd8dbeac27caf92a42e4ab to your computer and use it in GitHub Desktop.
Save samolabams/9cbe78934edd8dbeac27caf92a42e4ab to your computer and use it in GitHub Desktop.
Kubernetes resources for standing up Express Gateway
#!/bin/bash
kubectl create -f https://gist.githubusercontent.com/kevinswiber/e6a8245930676c3da3448b2bb79f23fd/raw/0869b72410851e2ab02d0c1c30443f4083345066/configmap.yaml
kubectl create -f https://gist.githubusercontent.com/kevinswiber/e6a8245930676c3da3448b2bb79f23fd/raw/0869b72410851e2ab02d0c1c30443f4083345066/deployment.yaml
kubectl create -f https://gist.githubusercontent.com/kevinswiber/e6a8245930676c3da3448b2bb79f23fd/raw/0869b72410851e2ab02d0c1c30443f4083345066/service.yaml
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: 'https://httpbin.org'
policies:
- jwt
- oauth2
- proxy
pipelines:
- name: default
apiEndpoints:
- api
policies:
# - jwt:
# - action:
# checkCredentialExistence: false
# secretOrPublicKeyFile: '/app/key.pem'
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
system.config.yml: |
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment