mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-04-07 19:46:57 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d6d0bed69 | ||
|
|
b213e0af0a | ||
|
|
42ad3faf5a | ||
|
|
939fd5b24d | ||
|
|
36ec3ef378 | ||
|
|
287e005129 | ||
|
|
0b3e88d6de | ||
|
|
10139749da | ||
|
|
f891e0683b | ||
|
|
647b4cba04 | ||
|
|
c5df50c774 | ||
|
|
2b1d325343 | ||
|
|
319d57cb68 |
@@ -19,12 +19,12 @@ jobs:
|
||||
|
||||
push-container:
|
||||
docker:
|
||||
- image: circleci/golang:1.12
|
||||
- image: circleci/golang:1.13
|
||||
working_directory: ~/build
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
docker_layer_caching: true
|
||||
docker_layer_caching: false
|
||||
- run: make build-container
|
||||
- run: |
|
||||
if [ -z "$CIRCLE_TAG" ]; then
|
||||
@@ -37,14 +37,14 @@ jobs:
|
||||
|
||||
push-binary:
|
||||
docker:
|
||||
- image: circleci/golang:1.12
|
||||
- image: circleci/golang:1.13
|
||||
steps:
|
||||
- checkout
|
||||
- run: curl -sL https://git.io/goreleaser | bash
|
||||
|
||||
push-helm-charts:
|
||||
docker:
|
||||
- image: circleci/golang:1.12
|
||||
- image: circleci/golang:1.13
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.12 as builder
|
||||
FROM golang:1.13 as builder
|
||||
|
||||
RUN mkdir -p /podinfo/
|
||||
|
||||
@@ -6,7 +6,7 @@ WORKDIR /podinfo
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN GOPROXY=https://proxy.golang.org go mod download
|
||||
RUN go mod download
|
||||
|
||||
RUN go test -v -race ./...
|
||||
|
||||
|
||||
4
Makefile
4
Makefile
@@ -10,7 +10,9 @@ GIT_COMMIT:=$(shell git describe --dirty --always)
|
||||
VERSION:=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | tr -d '"')
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
test:
|
||||
GO111MODULE=on go test -v -race ./...
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# podinfo
|
||||
|
||||
[](https://circleci.com/gh/stefanprodan/podinfo)
|
||||
[](https://goreportcard.com/report/github.com/stefanprodan/podinfo)
|
||||
[](https://hub.docker.com/r/stefanprodan/podinfo)
|
||||
|
||||
Podinfo is a tiny web application made with Go
|
||||
that showcases best practices of running microservices in Kubernetes.
|
||||
Podinfo is a tiny web application made with Go that showcases best practices of running microservices in Kubernetes.
|
||||
|
||||
Specifications:
|
||||
|
||||
@@ -13,6 +13,7 @@ Specifications:
|
||||
* File watcher for secrets and configmaps
|
||||
* Instrumented with Prometheus
|
||||
* Tracing with Istio and Jaeger
|
||||
* Linkerd service profile
|
||||
* Structured logging with zap
|
||||
* 12-factor app with viper
|
||||
* Fault injection (random errors and latency)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
apiVersion: v1
|
||||
version: 3.1.1
|
||||
appVersion: 3.1.1
|
||||
version: 3.1.3
|
||||
appVersion: 3.1.3
|
||||
name: podinfo
|
||||
engine: gotpl
|
||||
description: Podinfo Helm chart for Kubernetes
|
||||
|
||||
@@ -66,6 +66,7 @@ Parameter | Description | Default
|
||||
`tolerations` | list of node taints to tolerate | `[]`
|
||||
`serviceAccount.enabled` | specifies whether a service account should be created | `false`
|
||||
`serviceAccount.name` | the name of the service account to use, if not set and create is true, a name is generated using the fullname template | None
|
||||
`linkerd.profile.enabled` | create Linkerd service profile | `false`
|
||||
|
||||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
|
||||
|
||||
|
||||
@@ -55,9 +55,17 @@ spec:
|
||||
- --random-delay={{ .Values.faults.delay }}
|
||||
- --random-error={{ .Values.faults.error }}
|
||||
env:
|
||||
{{- if .Values.message }}
|
||||
{{- if .Values.ui.message }}
|
||||
- name: PODINFO_UI_MESSAGE
|
||||
value: {{ .Values.message }}
|
||||
value: {{ .Values.ui.message }}
|
||||
{{- end }}
|
||||
{{- if .Values.ui.logo }}
|
||||
- name: PODINFO_UI_LOGO
|
||||
value: {{ .Values.ui.logo }}
|
||||
{{- end }}
|
||||
{{- if .Values.ui.color }}
|
||||
- name: PODINFO_UI_COLOR
|
||||
value: {{ .Values.ui.color }}
|
||||
{{- end }}
|
||||
{{- if .Values.backend }}
|
||||
- name: PODINFO_BACKEND_URL
|
||||
|
||||
88
charts/podinfo/templates/linkerd.yaml
Normal file
88
charts/podinfo/templates/linkerd.yaml
Normal file
@@ -0,0 +1,88 @@
|
||||
{{- if .Values.linkerd.profile.enabled -}}
|
||||
apiVersion: linkerd.io/v1alpha2
|
||||
kind: ServiceProfile
|
||||
metadata:
|
||||
name: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
|
||||
spec:
|
||||
routes:
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /
|
||||
name: GET /
|
||||
- condition:
|
||||
method: POST
|
||||
pathRegex: /api/echo
|
||||
name: POST /api/echo
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /api/info
|
||||
name: GET /api/info
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /chunked/[^/]*
|
||||
name: GET /chunked/{seconds}
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /delay/[^/]*
|
||||
name: GET /delay/{seconds}
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /env
|
||||
name: GET /env
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /headers
|
||||
name: GET /headers
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /healthz
|
||||
name: GET /healthz
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /metrics
|
||||
name: GET /metrics
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /panic
|
||||
name: GET /panic
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /readyz
|
||||
name: GET /readyz
|
||||
- condition:
|
||||
method: POST
|
||||
pathRegex: /readyz/disable
|
||||
name: POST /readyz/disable
|
||||
- condition:
|
||||
method: POST
|
||||
pathRegex: /readyz/enable
|
||||
name: POST /readyz/enable
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /status/[^/]*
|
||||
name: GET /status/{code}
|
||||
- condition:
|
||||
method: POST
|
||||
pathRegex: /store
|
||||
name: POST /store
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /store/[^/]*
|
||||
name: GET /store/{hash}
|
||||
- condition:
|
||||
method: POST
|
||||
pathRegex: /token
|
||||
name: POST /token
|
||||
- condition:
|
||||
method: POST
|
||||
pathRegex: /token/validate
|
||||
name: POST /token/validate
|
||||
- condition:
|
||||
method: GET
|
||||
pathRegex: /version
|
||||
name: GET /version
|
||||
- condition:
|
||||
method: POST
|
||||
pathRegex: /ws/echo
|
||||
name: POST /ws/echo
|
||||
{{- end }}
|
||||
@@ -17,5 +17,5 @@ spec:
|
||||
- name: grpc-health-probe
|
||||
image: stefanprodan/grpc_health_probe:v0.3.0
|
||||
command: ['grpc_health_probe']
|
||||
args: ['-addr={{ template "podinfo.fullname" . }}:{{ .Values.service.grpcPort }}']
|
||||
args: ['-addr={{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.grpcPort }}']
|
||||
restartPolicy: Never
|
||||
|
||||
@@ -21,9 +21,9 @@ spec:
|
||||
- -c
|
||||
- |
|
||||
TOKEN=$(curl -sd 'test' ${PODINFO_SVC}/token | jq -r .token) &&
|
||||
curl -H "Authorization: Bearer ${TOKEN}" ${PODINFO_SVC}/token/validate | grep test
|
||||
curl -sH "Authorization: Bearer ${TOKEN}" ${PODINFO_SVC}/token/validate | grep test
|
||||
env:
|
||||
- name: PODINFO_SVC
|
||||
value: {{ template "podinfo.fullname" . }}:{{ .Values.service.externalPort }}
|
||||
value: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.externalPort }}
|
||||
restartPolicy: Never
|
||||
|
||||
|
||||
@@ -20,9 +20,8 @@ spec:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
TOKEN=$(curl -sd 'test' ${PODINFO_SVC}/token | jq -r .token) &&
|
||||
curl -H "Authorization: Bearer ${TOKEN}" ${PODINFO_SVC}/token/validate | grep test
|
||||
curl -s ${PODINFO_SVC}/api/info | grep version
|
||||
env:
|
||||
- name: PODINFO_SVC
|
||||
value: {{ template "podinfo.fullname" . }}:{{ .Values.service.externalPort }}
|
||||
value: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.externalPort }}
|
||||
restartPolicy: Never
|
||||
|
||||
@@ -4,7 +4,11 @@ replicaCount: 1
|
||||
logLevel: info
|
||||
backend: #http://backend-podinfo:9898/echo
|
||||
backends: []
|
||||
message: #UI greetings
|
||||
|
||||
ui:
|
||||
color: "cyan"
|
||||
message: ""
|
||||
logo: ""
|
||||
|
||||
faults:
|
||||
delay: false
|
||||
@@ -12,7 +16,7 @@ faults:
|
||||
|
||||
image:
|
||||
repository: stefanprodan/podinfo
|
||||
tag: 3.1.1
|
||||
tag: 3.1.3
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
service:
|
||||
@@ -43,6 +47,10 @@ serviceAccount:
|
||||
# If not set and create is true, a name is generated using the fullname template
|
||||
name:
|
||||
|
||||
linkerd:
|
||||
profile:
|
||||
enabled: false
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
annotations: {}
|
||||
|
||||
@@ -36,7 +36,8 @@ func main() {
|
||||
fs.String("config-path", "", "config dir path")
|
||||
fs.String("config", "config.yaml", "config file name")
|
||||
fs.String("ui-path", "./ui", "UI local path")
|
||||
fs.String("ui-color", "blue", "UI color")
|
||||
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("random-delay", false, "between 0 and 5 seconds random delay")
|
||||
fs.Bool("random-error", false, "1/3 chances of a random response error")
|
||||
@@ -64,6 +65,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.Set("hostname", hostname)
|
||||
viper.Set("version", version.VERSION)
|
||||
viper.Set("revision", version.REVISION)
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
||||
module github.com/stefanprodan/podinfo
|
||||
|
||||
go 1.12
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
|
||||
|
||||
@@ -25,7 +25,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: podinfod
|
||||
image: stefanprodan/podinfo:3.1.1
|
||||
image: stefanprodan/podinfo:3.1.3
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
@@ -48,7 +48,7 @@ spec:
|
||||
- --random-error=false
|
||||
env:
|
||||
- name: PODINFO_UI_COLOR
|
||||
value: blue
|
||||
value: cyan
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
|
||||
@@ -23,8 +23,10 @@ func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
data := struct {
|
||||
Title string
|
||||
Logo string
|
||||
}{
|
||||
Title: s.config.Hostname,
|
||||
Logo: s.config.UILogo,
|
||||
}
|
||||
|
||||
if err := tmpl.Execute(w, data); err != nil {
|
||||
|
||||
@@ -22,6 +22,7 @@ func (s *Server) infoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
Hostname: s.config.Hostname,
|
||||
Version: version.VERSION,
|
||||
Revision: version.REVISION,
|
||||
Logo: s.config.UILogo,
|
||||
Color: s.config.UIColor,
|
||||
Message: s.config.UIMessage,
|
||||
GOOS: runtime.GOOS,
|
||||
@@ -39,6 +40,7 @@ type RuntimeResponse struct {
|
||||
Version string `json:"version"`
|
||||
Revision string `json:"revision"`
|
||||
Color string `json:"color"`
|
||||
Logo string `json:"logo"`
|
||||
Message string `json:"message"`
|
||||
GOOS string `json:"goos"`
|
||||
GOARCH string `json:"goarch"`
|
||||
|
||||
@@ -50,6 +50,7 @@ type Config struct {
|
||||
HttpServerTimeout time.Duration `mapstructure:"http-server-timeout"`
|
||||
HttpServerShutdownTimeout time.Duration `mapstructure:"http-server-shutdown-timeout"`
|
||||
BackendURL []string `mapstructure:"backend-url"`
|
||||
UILogo string `mapstructure:"ui-logo"`
|
||||
UIMessage string `mapstructure:"ui-message"`
|
||||
UIColor string `mapstructure:"ui-color"`
|
||||
UIPath string `mapstructure:"ui-path"`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package version
|
||||
|
||||
var VERSION = "3.1.1"
|
||||
var VERSION = "3.1.3"
|
||||
var REVISION = "unknown"
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
<v-app dark>
|
||||
<v-content>
|
||||
<section>
|
||||
<v-parallax id="parallax-hero" src="#" :class="info.color">
|
||||
<v-parallax id="parallax-hero" src="https://upload.wikimedia.org/wikipedia/commons/c/ca/1x1.png" :class="info.color">
|
||||
<v-layout
|
||||
column
|
||||
align-center
|
||||
justify-center
|
||||
class="white--text"
|
||||
>
|
||||
<img src="https://d33wubrfki0l68.cloudfront.net/33a12d8be0bc50be4738443101616e968c7afb8f/cba76/images/scalable.png" alt="kubernetes" height="200">
|
||||
<img :src="info.logo" alt="kubernetes" height="200">
|
||||
<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
|
||||
@@ -108,7 +108,8 @@
|
||||
}
|
||||
}
|
||||
self.info = data
|
||||
self.info.color = 'cyan'
|
||||
self.info.color = data.color
|
||||
self.info.logo = data.logo
|
||||
document.title = data.hostname
|
||||
let verColor = (parseInt(data.version.split('.').reverse()[0], 10) % 2 === 0)
|
||||
? 'blue'
|
||||
|
||||
Reference in New Issue
Block a user