Skip to content

Instantly share code, notes, and snippets.

apiVersion: v1
kind: Service
metadata:
  name: echoheadersx
  labels:
    app: echoheaders
spec:
  type: NodePort
  ports:
@bprashanth
bprashanth / l7_debug.md
Last active March 23, 2016 23:18
L7 debug

What's the restart count on the pod?
what's the output of

$ kubectl logs --namespace=kube-system exec l7-lb-controller-v0.5.2-apv4a -c l7-lb-controller 

If it's restarting, can you please try:

$ kubectl --namespace=kube-system exec l7-lb-controller-v0.5.2-apv4a -c l7-lb-controller -- curl --silent localhost:8080/healthz
It should return a 200 and the string "ok".

Needs bprashanth/glbc:0.6.2

Create the static ip:

$ gcloud compute addresses create staticip --global
NAME     REGION ADDRESS       STATUS
staticip        107.some.ip RESERVED

Specify the annotation (this step assumes you have a secret called testsecret and a service called haproxy):

Start 2 kubernetes clusters.

Pick 1 node and label it as role=loadbalancer:

$ kubectl get nodes
NAME                              STATUS    AGE
gke-failover-c93a5565-node-bilp   Ready     1h
gke-failover-c93a5565-node-siro   Ready     1h
gke-failover-c93a5565-node-woat   Ready     1h
@bprashanth
bprashanth / https-sticky.md
Last active February 19, 2018 18:54
https sticky sessions

Create a backend service that simply serves the pod name, and a frontend haproxy instance that balances based on client cookies.

# This is the backend service
apiVersion: v1
kind: Service
metadata:
  name: hostname
  annotations:
    # Enable sticky-ness on "SERVERID"
    serviceloadbalancer/lb.cookie-sticky-session: "true"
@bprashanth
bprashanth / stickysessions.md
Last active July 29, 2016 21:30
sticky sessions

Create a backend service that simply serves the pod name, and a frontend haproxy instance that balances based on client cookies.

# This is the backend service
apiVersion: v1
kind: Service
metadata:
  name: hostname
  annotations:
    # Enable sticky-ness on "SERVERID"
    serviceloadbalancer/lb.cookie-sticky-session: "true"
$ sudo cat /lib/systemd/system/test.service 
[Unit]
Description=test

[Service]
WatchdogSec=5s
ExecStart=/tmp/test
Restart=always
I0122 11:19:50.919737 3399 config.go:412] Receiving a new pod "daemonrestart10-e44fe05e-c0f9-11e5-a7e6-ac162d075328-go7lw_e2e-tests-daemonrestart-9gi0h(0d81a7f0-c0fa-11e5-a227-42010af00002)"
I0122 11:19:50.922752 3399 kubelet.go:2289] SyncLoop (ADD, "api"): "daemonrestart10-e44fe05e-c0f9-11e5-a7e6-ac162d075328-go7lw_e2e-tests-daemonrestart-9gi0h(0d81a7f0-c0fa-11e5-a227-42010af00002)"
I0122 11:19:51.308004 3399 kubelet.go:2292] SyncLoop (UPDATE, "api"): "daemonrestart10-e44fe05e-c0f9-11e5-a7e6-ac162d075328-go7lw_e2e-tests-daemonrestart-9gi0h(0d81a7f0-c0fa-11e5-a227-42010af00002)"
I0122 11:19:51.373171 3399 kubelet.go:1701] Reusing api pod status for new pod "daemonrestart10-e44fe05e-c0f9-11e5-a7e6-ac162d075328-go7lw_e2e-tests-daemonrestart-9gi0h(0d81a7f0-c0fa-11e5-a227-42010af00002)"
I0122 11:19:51.373190 3399 manager.go:1657] Syncing Pod "daemonrestart10-e44fe05e-c0f9-11e5-a7e6-ac162d075328-go7lw_e2e-tests-daemonrestart-9gi0h(0d81a7f0-c0fa-11e5-a227-42010af00002)": &{TypeMeta:{Kind: APIVersion:
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "clusterapi-tester"
},
"spec": {
"containers": [
{
"name": "clusterapi",
16:57:52-beeps~/goproj/src/k8s.io/contrib/service-loadbalancer] (master)$ make
CGO_ENABLED=0 GOOS=linux godep go build -a -installsuffix cgo -ldflags '-w' -o service_loadbalancer ./service_loadbalancer.go ./loadbalancer_log.go
docker build -t contrib-haproxy:0.0 build
Sending build context to Docker daemon 9.216 kB
Step 1 : FROM alpine:3.2
---> 8a648f689ddb
Step 2 : RUN apk -U add alpine-sdk
---> Using cache
---> 5c5a490ddf56
Step 3 : RUN mkdir -p /var/cache/distfiles && adduser -D packager && addgroup packager abuild && chgrp abuild /var/cache/distfiles && chmod g+w /var/cache/distfiles && echo "packager ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers