mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-04-07 03:26:54 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af6868a8de | ||
|
|
910e7139f9 | ||
|
|
fe65869b6b | ||
|
|
2a319d9d0d | ||
|
|
48402eff7e | ||
|
|
15600cc7d3 | ||
|
|
ed2a774e10 | ||
|
|
1d590c07cb | ||
|
|
948de81ed3 | ||
|
|
78658c0311 | ||
|
|
7b6f11780a |
@@ -11,7 +11,7 @@ jobs:
|
||||
name: Start Kubernetes Kind cluster
|
||||
command: e2e/bootstrap.sh
|
||||
- run:
|
||||
name: Install podinfo with Helm
|
||||
name: Install podinfo with Helm v3
|
||||
command: e2e/install.sh
|
||||
- run:
|
||||
name: Run Helm tests
|
||||
|
||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -1,5 +1,5 @@
|
||||
on: [push, pull_request]
|
||||
name: kustomize
|
||||
name: test
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
3
Makefile
3
Makefile
@@ -8,11 +8,12 @@ DOCKER_REPOSITORY:=stefanprodan
|
||||
DOCKER_IMAGE_NAME:=$(DOCKER_REPOSITORY)/$(NAME)
|
||||
GIT_COMMIT:=$(shell git describe --dirty --always)
|
||||
VERSION:=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | tr -d '"')
|
||||
EXTRA_RUN_ARGS?=
|
||||
|
||||
run:
|
||||
GO111MODULE=on go run -ldflags "-s -w -X github.com/stefanprodan/podinfo/pkg/version.REVISION=$(GIT_COMMIT)" cmd/podinfo/* \
|
||||
--level=debug --grpc-port=9999 --backend-url=https://httpbin.org/status/401 --backend-url=https://httpbin.org/status/500 \
|
||||
--ui-logo=https://media.giphy.com/media/l0ExbNdlJFGRphMR2/giphy.gif
|
||||
--ui-logo=https://raw.githubusercontent.com/stefanprodan/podinfo/gh-pages/cuddle_clap.gif --ui-color=#34577c $(EXTRA_RUN_ARGS)
|
||||
|
||||
test:
|
||||
GO111MODULE=on go test -v -race ./...
|
||||
|
||||
@@ -53,7 +53,7 @@ gRPC API:
|
||||
|
||||
Web UI:
|
||||
|
||||

|
||||

|
||||
|
||||
To access the Swagger UI open `<podinfo-host>/swagger/index.html` in a browser.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
apiVersion: v1
|
||||
version: 3.1.4
|
||||
appVersion: 3.1.4
|
||||
version: 3.2.0
|
||||
appVersion: 3.2.0
|
||||
name: podinfo
|
||||
engine: gotpl
|
||||
description: Podinfo Helm chart for Kubernetes
|
||||
|
||||
@@ -36,6 +36,8 @@ Parameter | Description | Default
|
||||
`backends` | echo backend URL array | None
|
||||
`faults.delay` | random HTTP response delays between 0 and 5 seconds | `false`
|
||||
`faults.error` | 1/3 chances of a random HTTP response error | `false`
|
||||
`faults.unhealthy` | when set, the healthy state is never reached | `false`
|
||||
`faults.unready` | when set, the ready state is never reached | `false`
|
||||
`hpa.enabled` | enables HPA | `false`
|
||||
`hpa.cpu` | target CPU usage per pod | None
|
||||
`hpa.memory` | target memory usage per pod | None
|
||||
|
||||
@@ -54,6 +54,12 @@ spec:
|
||||
- --level={{ .Values.logLevel }}
|
||||
- --random-delay={{ .Values.faults.delay }}
|
||||
- --random-error={{ .Values.faults.error }}
|
||||
{{- if .Values.faults.unhealthy }}
|
||||
- --unhealthy
|
||||
{{- end }}
|
||||
{{- if .Values.faults.unready }}
|
||||
- --unready
|
||||
{{- end }}
|
||||
{{- if .Values.h2c.enabled }}
|
||||
- --h2c
|
||||
{{- end }}
|
||||
|
||||
@@ -5,7 +5,7 @@ metadata:
|
||||
name: {{ template "podinfo.fullname" . }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1beta2
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ template "podinfo.fullname" . }}
|
||||
minReplicas: {{ .Values.replicaCount }}
|
||||
|
||||
@@ -6,20 +6,22 @@ backend: #http://backend-podinfo:9898/echo
|
||||
backends: []
|
||||
|
||||
ui:
|
||||
color: "cyan"
|
||||
color: "#34577c"
|
||||
message: ""
|
||||
logo: ""
|
||||
|
||||
faults:
|
||||
delay: false
|
||||
error: false
|
||||
unhealthy: false
|
||||
unready: false
|
||||
|
||||
h2c:
|
||||
enabled: false
|
||||
|
||||
image:
|
||||
repository: stefanprodan/podinfo
|
||||
tag: 3.1.4
|
||||
tag: 3.2.0
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
service:
|
||||
|
||||
@@ -39,10 +39,12 @@ func main() {
|
||||
fs.String("ui-logo", "", "UI logo")
|
||||
fs.String("ui-color", "cyan", "UI color")
|
||||
fs.String("ui-message", fmt.Sprintf("greetings from podinfo v%v", version.VERSION), "UI message")
|
||||
fs.Bool("h2c", false, "Allow upgrading to H2C")
|
||||
fs.Bool("h2c", false, "allow upgrading to H2C")
|
||||
fs.Bool("random-delay", false, "between 0 and 5 seconds random delay")
|
||||
fs.Bool("random-error", false, "1/3 chances of a random response error")
|
||||
fs.Int("stress-cpu", 0, "Number of CPU cores with 100 load")
|
||||
fs.Bool("unhealthy", false, "when set, healthy state is never reached")
|
||||
fs.Bool("unready", false, "when set, ready state is never reached")
|
||||
fs.Int("stress-cpu", 0, "number of CPU cores with 100 load")
|
||||
fs.Int("stress-memory", 0, "MB of data to load into memory")
|
||||
|
||||
versionFlag := fs.BoolP("version", "v", false, "get version number")
|
||||
@@ -66,7 +68,7 @@ func main() {
|
||||
viper.RegisterAlias("backendUrl", "backend-url")
|
||||
hostname, _ := os.Hostname()
|
||||
viper.SetDefault("jwt-secret", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9")
|
||||
viper.SetDefault("ui-logo", "https://d33wubrfki0l68.cloudfront.net/33a12d8be0bc50be4738443101616e968c7afb8f/cba76/images/scalable.png")
|
||||
viper.SetDefault("ui-logo", "https://raw.githubusercontent.com/stefanprodan/podinfo/gh-pages/cuddle_clap.gif")
|
||||
viper.Set("hostname", hostname)
|
||||
viper.Set("version", version.VERSION)
|
||||
viper.Set("revision", version.REVISION)
|
||||
|
||||
@@ -7,11 +7,11 @@ The e2e testing infrastructure is powered by CircleCI and [Kubernetes Kind](http
|
||||
* download go modules
|
||||
* run unit tests
|
||||
* build container
|
||||
* install kubectl, helm and Kubernetes Kind CLIs
|
||||
* install kubectl, Helm v3 and Kubernetes Kind CLIs
|
||||
* create local Kubernetes cluster with kind
|
||||
* deploy Tiller on the local cluster
|
||||
* load podinfo image onto the local cluster
|
||||
* deploy podinfo with Helm
|
||||
* set the podinfo image to the locally built one
|
||||
* run Helm tests
|
||||
|
||||
```yaml
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
set -o errexit
|
||||
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
KIND_VERSION=v0.5.1
|
||||
KIND_VERSION=v0.7.0
|
||||
|
||||
if [[ "$1" ]]; then
|
||||
KIND_VERSION=$1
|
||||
@@ -22,13 +22,5 @@ sudo mv kind /usr/local/bin/kind
|
||||
echo ">>> Creating kind cluster"
|
||||
kind create cluster --wait 5m
|
||||
|
||||
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
|
||||
kubectl get pods --all-namespaces
|
||||
|
||||
echo ">>> Installing Helm"
|
||||
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
|
||||
|
||||
echo '>>> Installing Tiller'
|
||||
kubectl --namespace kube-system create sa tiller
|
||||
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
|
||||
helm init --service-account tiller --upgrade --wait
|
||||
echo ">>> Installing Helm v3"
|
||||
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
set -o errexit
|
||||
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
|
||||
|
||||
echo '>>> Loading image in Kind'
|
||||
kind load docker-image test/podinfo:latest
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
|
||||
set -o errexit
|
||||
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
|
||||
|
||||
function finish {
|
||||
echo '>>> Test logs'
|
||||
kubectl logs -l app=podinfo
|
||||
}
|
||||
trap finish EXIT
|
||||
|
||||
echo '>>> Testing'
|
||||
echo '>>> Start integration tests'
|
||||
helm test podinfo
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: podinfod
|
||||
image: stefanprodan/podinfo:3.1.4
|
||||
image: stefanprodan/podinfo:3.2.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
@@ -48,7 +48,7 @@ spec:
|
||||
- --random-error=false
|
||||
env:
|
||||
- name: PODINFO_UI_COLOR
|
||||
value: cyan
|
||||
value: "#34577c"
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
|
||||
@@ -65,6 +65,8 @@ type Config struct {
|
||||
H2C bool `mapstructure:"h2c"`
|
||||
RandomDelay bool `mapstructure:"random-delay"`
|
||||
RandomError bool `mapstructure:"random-error"`
|
||||
Unhealthy bool `mapstructure:"unhealthy"`
|
||||
Unready bool `mapstructure:"unready"`
|
||||
JWTSecret string `mapstructure:"jwt-secret"`
|
||||
}
|
||||
|
||||
@@ -181,8 +183,12 @@ func (s *Server) ListenAndServe(stopCh <-chan struct{}) {
|
||||
}()
|
||||
|
||||
// signal Kubernetes the server is ready to receive traffic
|
||||
atomic.StoreInt32(&healthy, 1)
|
||||
atomic.StoreInt32(&ready, 1)
|
||||
if !s.config.Unhealthy {
|
||||
atomic.StoreInt32(&healthy, 1)
|
||||
}
|
||||
if !s.config.Unready {
|
||||
atomic.StoreInt32(&ready, 1)
|
||||
}
|
||||
|
||||
// wait for SIGTERM or SIGINT
|
||||
<-stopCh
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package version
|
||||
|
||||
var VERSION = "3.1.4"
|
||||
var VERSION = "3.2.0"
|
||||
var REVISION = "unknown"
|
||||
|
||||
20
ui/vue.html
20
ui/vue.html
@@ -10,8 +10,11 @@
|
||||
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none;
|
||||
}
|
||||
display: none;
|
||||
}
|
||||
.v-application .v-parallax {
|
||||
height: 100vh !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -19,14 +22,14 @@
|
||||
<v-app dark>
|
||||
<v-content>
|
||||
<section>
|
||||
<v-parallax id="parallax-hero" src="https://upload.wikimedia.org/wikipedia/commons/c/ca/1x1.png" :class="info.color">
|
||||
<v-parallax id="parallax-hero" :style="cuddleStyle" src="https://upload.wikimedia.org/wikipedia/commons/c/ca/1x1.png">
|
||||
<v-layout
|
||||
column
|
||||
align-center
|
||||
justify-center
|
||||
class="white--text"
|
||||
>
|
||||
<img :src="info.logo" alt="kubernetes" height="200">
|
||||
<img :src="info.logo" height="350">
|
||||
<h1 class="white--text mb-2 display-1 text-xs-center">${ info.message }</h1>
|
||||
<div class="subheading mb-3 text-xs-center">Served by <b>${ info.hostname }</b></div>
|
||||
<v-btn
|
||||
@@ -86,11 +89,11 @@
|
||||
tlColor1: 'grey',
|
||||
tlName2: '',
|
||||
tlColor2: 'grey',
|
||||
cuddleStyle: {
|
||||
backgroundColor: '#34577c'
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
document.getElementById('parallax-hero').style.height = '100vh'
|
||||
},
|
||||
created: function() {
|
||||
this.getInfo();
|
||||
this.timer = setInterval(this.getInfo, 3000)
|
||||
@@ -109,6 +112,9 @@
|
||||
}
|
||||
self.info = data
|
||||
self.info.color = data.color
|
||||
self.cuddleStyle = {
|
||||
backgroundColor: data.color
|
||||
}
|
||||
self.info.logo = data.logo
|
||||
document.title = data.hostname
|
||||
let verColor = (parseInt(data.version.split('.').reverse()[0], 10) % 2 === 0)
|
||||
|
||||
Reference in New Issue
Block a user