Created
October 30, 2021 21:36
-
-
Save a1994sc/7f66b821080d9b0e38c2cf43ab548e55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: xbs-config | |
namespace: apps | |
data: | |
healthcheck.js: | | |
const http = require('http'); | |
const response = http.request( | |
{ | |
host: '0.0.0.0', | |
method: 'GET', | |
path: '/info', | |
port: 8080, | |
timeout: 2000, | |
}, | |
(res) => { | |
let body = ''; | |
res.setEncoding('utf8'); | |
res.on('data', (chunk) => { | |
body += chunk; | |
}); | |
res.on('end', () => { | |
if (res.statusCode === 200) { | |
const payload = JSON.parse(body); | |
switch (payload.status) { | |
case 1: | |
case 3: | |
console.log('HEALTHCHECK: online'); | |
process.exit(0); | |
case 2: | |
default: | |
console.log('HEALTHCHECK: offline'); | |
} | |
} else { | |
console.log('HEALTHCHECK: offline'); | |
} | |
process.exit(1); | |
}); | |
} | |
); | |
response.on('error', function (err) { | |
console.log('HEALTHCHECK: offline'); | |
process.exit(1); | |
}); | |
response.end(); | |
settings.json: | | |
{ | |
"db": { | |
"host": "mongo.ingress.svc.cluster.local", | |
"name": "xbrowsersync", | |
"username": "sxbs", | |
"password": "password123", | |
"authSource": "xbrowsersync" | |
}, | |
"maxSyncs": 0, | |
"maxSyncSize": 1024000000, | |
"status": { | |
"allowNewSyncs": false, | |
"message": "Derpaholic xBrowserSync." | |
}, | |
"server": { | |
"behindProxy": true, | |
"host": "xbs.derpaholic.com", | |
"https": { | |
"certPath": "", | |
"enabled": false, | |
"keyPath": "" | |
}, | |
"port": 8080, | |
"relativePath": "/" | |
}, | |
"dailyNewSyncsLimit": 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
kind: Deployment | |
apiVersion: apps/v1 | |
metadata: | |
name: xbrowser-api | |
namespace: apps | |
labels: | |
app: xbs-api | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: xbs-api | |
template: | |
metadata: | |
labels: | |
app: xbs-api | |
spec: | |
containers: | |
- name: xbs-api-pod | |
image: xbrowsersync/api:v1.1.13 | |
imagePullPolicy: IfNotPresent | |
resources: | |
limits: | |
cpu: "100m" | |
memory: "128Mi" | |
requests: | |
cpu: "25m" | |
memory: "32Mi" | |
# command: | |
# - tail | |
# - -f | |
# - /dev/null | |
volumeMounts: | |
- name: config-volume | |
mountPath: /usr/src/api/config | |
# subPath: settings.json | |
# - name: health-volume | |
# mountPath: /usr/src/api | |
# subPath: healthcheck.js | |
# livenessProbe: | |
# exec: | |
# command: | |
# - node | |
# - /usr/src/api/healthcheck.js | |
# initialDelaySeconds: 5 | |
# periodSeconds: 60 | |
volumes: | |
- name: config-volume | |
configMap: | |
name: xbs-config | |
# - name: health-volume | |
# configMap: | |
# name: xbs-health-check | |
nodeSelector: | |
kubernetes.io/arch: "amd64" | |
dnsPolicy: ClusterFirst | |
restartPolicy: Always |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment