Giter Club home page Giter Club logo

telepolice's Introduction

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.

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

telepolice's People

Contributors

takumakume avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

t1loc

telepolice's Issues

Docker image

For some security reasons and/or best practice, a docker image should run as a standard user instead of root.
Instruction COPY is used in favor to ADD.

You can also add the build process as a build stage

FROM golang:XXXX as builder # Update XXX

...
build command
...

FROM debian:stable-slim

RUN apt-get update && apt-get -uy upgrade && \
         apt-get -y install ca-certificates && update-ca-certificates && \
         ... command to clear apt cache (to slim the image) ... 



COPY --from=builder dist/telepolice_linux_amd64/telepolice /telepolice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.