Skip to content

Latest commit

 

History

History
156 lines (114 loc) · 3.67 KB

README.md

File metadata and controls

156 lines (114 loc) · 3.67 KB

telepolice Build Status GitHub release

This tool is telepresenceio/telepresence cleaner.

Using telepresence --swap-deployment , telepresence deployment does not work if process crashes or laptop is closed. (ref: telepresenceio/telepresence#260)

image

Clean according to the following flow.

  1. Collect pods with telepresence labels in the specified namespace.
  2. Check if a valid sshd process exists for those pods. If it does not exist, it is broken. (*1)
  3. Perform the same processing as the Telepresence Cleanup on the invalid Pods.
(*1) Broken Pod status

When telepresence is working:

~ $ ps -elf
PID   USER     TIME   COMMAND
    1 telepres   0:00 {twistd} /usr/bin/python3.6 /usr/bin/twistd --pidfile= -n -y ./forwarder.py
    8 telepres   0:00 [sshd]
    9 telepres   0:00 /usr/sbin/sshd -e
   14 telepres   0:00 [sshd]
   17 telepres   0:00 sshd: telepresence [priv]
   18 telepres   0:00 sshd: telepresence [priv]
   21 telepres   0:00 sshd: telepresence
   22 telepres   0:00 sshd: telepresence
   28 telepres   0:00 sshd: telepresence [priv]
   30 telepres   0:00 sshd: telepresence@notty
   31 telepres   0:00 ash -c /usr/lib/ssh/sftp-server
   32 telepres   0:00 /usr/lib/ssh/sftp-server
   34 telepres   0:00 sh
   39 telepres   0:00 ps -elf

When telepresence is not working:

~ $ ps -elf
PID   USER     TIME   COMMAND
    1 telepres   0:00 {twistd} /usr/bin/python3.6 /usr/bin/twistd --pidfile= -n -y ./forwarder.py
    8 telepres   0:00 [sshd]
    9 telepres   0:00 /usr/sbin/sshd -e
   14 telepres   0:00 [sshd]
   21 telepres   0:00 [sshd]
   22 telepres   0:00 [sshd]
   30 telepres   0:00 [sshd]
   31 telepres   0:00 [ash]
   34 telepres   0:00 sh
   43 telepres   0:00 ps -elf

telepolice sees the state of sshd process.

Usage

Get telepresence resources

$ telepolice get
NAMESPACE STATUS POD
default   true   web-9bc4ceefeade40668638a0b782decec9-57f78598krqr

Broken case (STATUS = false)

$ telepolice get
NAMESPACE STATUS POD
default   false  web-9bc4ceefeade40668638a0b782decec9-57f78598krqr

Cleanup telepresence resources

% telepolice cleanup
Cleanup: default/web-9bc4ceefeade40668638a0b782decec9-57f78598krqr

Dry run mode by adding --dry-run option.

Use cases

Perform cleanup at intervals

$ telepolice cleanup -i 60

Start as a daemon in the foreground. Clean every 60 seconds.

Target some namespaces

$ telepolice get -n ns1,ns2

default: default namespace

Target all namespaces

$ telepolice get -A

Specify kubeconfig

$ KUBECONFIG=~/.kube/other_config telepolice get

default: ~/.kube/config

Use in cluser config (kubernetes ServiceAccount)

$ telepolice --use-in-cluster-config get

Install as a cleaner on kubernetes

  • use master
    kubectl apply -f https://raw.githubusercontent.com/takumakume/telepolice/master/manifests/release.yaml
  • use tag
    kubectl apply -f https://raw.githubusercontent.com/takumakume/telepolice/v0.0.1/manifests/release.yaml

Custom configration

apiVersion: v1
kind: ConfigMap
metadata:
  name: telepolice-config
  namespace: telepolice
data:
  arg: "cleanup --use-in-cluster-config -A -i 30 --verbose"

edit arg

Install Cli tool

go get github.com/takumakume/telepolice