Skip to content

Instantly share code, notes, and snippets.

@ldemailly
Last active September 17, 2021 16:23
Show Gist options
  • Save ldemailly/6f54d33c757af5d70a358a83cf1b7abb to your computer and use it in GitHub Desktop.
Save ldemailly/6f54d33c757af5d70a358a83cf1b7abb to your computer and use it in GitHub Desktop.
fortio 3 layer with fan out of 2 both tcp and http
apiVersion: v1
kind: Namespace
metadata:
name: fortio
labels:
istio-injection: enabled
---
# Service "A" definition
apiVersion: v1
kind: Service
metadata:
name: fortio-client
namespace: fortio
spec:
ports:
- port: 8080
name: http-fortio
selector:
app: fortio-client
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fortio-client-deployment
namespace: fortio
spec:
replicas: 1 # tells deployment to run 1 pod(s) matching the template
selector:
matchLabels:
app: fortio-client
template: # create pods using pod definition in this template
metadata:
# a unique name is generated from the deployment name
labels:
app: fortio-client
spec:
containers:
- name: fortio-client
image: fortio/fortio:FORTIO_VERSION
imagePullPolicy: Always # needed despite what is documented to really get latest
ports:
- containerPort: 8078 # tcp echo
- containerPort: 8079 # grpc echo
- containerPort: 8080 # main serving port
- containerPort: 8081 # redirection to https port
args:
- server
- -echo-debug-path
- /fortio/debug/
#- -loglevel
#- verbose
volumeMounts:
- mountPath: /var/lib/fortio
name: fortio-data
volumes:
- name: fortio-data
emptyDir:
medium: Memory
---
# Alias for fortio-client
apiVersion: v1
kind: Service
metadata:
name: fortio-a
namespace: fortio
spec:
ports:
- port: 8080
name: http-fortio
selector:
app: fortio-client
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fortio-http-proxy-parallel
namespace: fortio
spec:
replicas: 1 # tells deployment to run 1 pods matching the template
selector:
matchLabels:
app: fortio-http-proxy-parallel
template: # create pods using pod definition in this template
metadata:
# a unique name is generated from the deployment name
labels:
app: fortio-http-proxy-parallel
spec:
containers:
- name: fortio-http-proxy-parallel
image: fortio/fortio:FORTIO_VERSION
imagePullPolicy: Always
ports:
- containerPort: 8088 # 'http' proxy to C1
args:
- proxies
- -M
- 8088 http://fortio-c1-http:8080 http://fortio-c2-http:8080 # fan out 2x
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fortio-http-proxy-serial
namespace: fortio
spec:
replicas: 1 # tells deployment to run 1 pods matching the template
selector:
matchLabels:
app: fortio-http-proxy-serial
template: # create pods using pod definition in this template
metadata:
# a unique name is generated from the deployment name
labels:
app: fortio-http-proxy-serial
spec:
containers:
- name: fortio-http-proxy-serial
image: fortio/fortio:FORTIO_VERSION
imagePullPolicy: Always
ports:
- containerPort: 8088 # 'http' proxy to C1
args:
- proxies
- -multi-serial-mode
- -M
- 8088 http://fortio-c1-http:8080 http://fortio-c2-http:8080 # fan out 2x
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fortio-tcp-proxy
namespace: fortio
spec:
replicas: 1 # tells deployment to run 1 pods matching the template
selector:
matchLabels:
app: fortio-tcp-proxy
template: # create pods using pod definition in this template
metadata:
# a unique name is generated from the deployment name
labels:
app: fortio-tcp-proxy
spec:
containers:
- name: fortio-tcp-proxy
image: fortio/fortio:FORTIO_VERSION
imagePullPolicy: Always
ports:
- containerPort: 8089 # tcp proxy to C2
args:
- server
- -P
- 8089 fortio-c-tcp:8078
---
apiVersion: v1
kind: Service
metadata:
name: fortio-b-http-parallel
namespace: fortio
spec:
ports:
- port: 8088
name: http-proxy
selector:
app: fortio-http-proxy-parallel
---
apiVersion: v1
kind: Service
metadata:
name: fortio-b-http-serial
namespace: fortio
spec:
ports:
- port: 8088
name: http-proxy
selector:
app: fortio-http-proxy-serial
---
apiVersion: v1
kind: Service
metadata:
name: fortio-b-tcp
namespace: fortio
spec:
ports:
- port: 8089
name: tcp-proxy
selector:
app: fortio-tcp-proxy
---
apiVersion: v1
kind: Service
metadata:
name: fortio-c1-http
namespace: fortio
spec:
ports:
- port: 8080
name: http-echo
selector:
app: fortio-server-1
---
# Same deployment/svc under 2 names so the proxy fan out makes a nice graph
apiVersion: v1
kind: Service
metadata:
name: fortio-c2-http
namespace: fortio
spec:
ports:
- port: 8080
name: http-echo
selector:
app: fortio-server-1
---
apiVersion: v1
kind: Service
metadata:
name: fortio-c-tcp
namespace: fortio
spec:
ports:
- port: 8078
name: tcp-echo
selector:
app: fortio-server-2
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fortio-server-deployment-1
namespace: fortio
spec:
replicas: 2 # tells deployment to run 2 pods matching the template
selector:
matchLabels:
app: fortio-server-1
template: # create pods using pod definition in this template
metadata:
# a unique name is generated from the deployment name
labels:
app: fortio-server-1
spec:
containers:
- name: fortio-server
image: fortio/fortio:FORTIO_VERSION
imagePullPolicy: Always
ports:
- containerPort: 8078 # tcp echo
- containerPort: 8079 # grpc echo
- containerPort: 8080 # http echo/debug
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fortio-server-deployment-2
namespace: fortio
spec:
replicas: 2 # tells deployment to run 2 pods matching the template
selector:
matchLabels:
app: fortio-server-2
template: # create pods using pod definition in this template
metadata:
# a unique name is generated from the deployment name
labels:
app: fortio-server-2
spec:
containers:
- name: fortio-server-2
image: fortio/fortio:FORTIO_VERSION
imagePullPolicy: Always
ports:
- containerPort: 8078 # tcp echo
- containerPort: 8079 # grpc echo
- containerPort: 8080 # http echo/debug
@ldemailly
Copy link
Author

install with makefile:

FORTIO_VERSION:=1.11.2

fortio: fortio.yaml
	sed -e "s%FORTIO_VERSION%$(FORTIO_VERSION)%g" $< | kubectl apply -f -

FORTIO_CLIENT_POD=$(shell $(KUBECTL) get pods -n fortio -l app=fortio-client -o=jsonpath={.items[0].metadata.name})

fortio-connect:
#@echo "Fortio client pod is $(FORTIO_CLIENT_POD)"
	$(KUBECTL) port-forward -n fortio $(FORTIO_CLIENT_POD) $(LOCAL_FORTIO_PORT):8080 &
	open http://localhost:$(LOCAL_FORTIO_PORT)/fortio

@ldemailly
Copy link
Author

use 1.17.0 by now

@ldemailly
Copy link
Author

then use
fortio-b-http-parallel:8088/echo
as the URL

Screen Shot 2021-09-17 at 9 22 40 AM

for kiali/kiali#4366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment