telepolice

command module
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 1 Imported by: 0

README

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: https://github.com/telepresenceio/telepresence/issues/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.

Add annotations to deployment

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: app-deployment
spec:
  annotations:
    telepolice/original-deployment: app-deployment
    telepolice/original-deployment-replicas: 1
...

Previously, metadata.selflink of last-applied-configuration of annotations was used, but it became deprecated.

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

Documentation

Overview

Copyright © 2020 takumakume

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL