Skip to content

Instantly share code, notes, and snippets.

View kainlite's full-sized avatar
:shipit:

Gabriel Garrido kainlite

:shipit:
View GitHub Profile
export TF_VAR_DO_TOKEN=insert_your_token_here
@kainlite
kainlite / kubectl-root-in-host.sh
Created June 20, 2019 14:51 — forked from jjo/kubectl-root-in-host-nopriv.sh
Yeah. Get a root shell at any Kubernetes *node* via `privileged: true` + `nsenter` sauce. PodSecurityPolicies will save us.
#!/bin/sh
node=${1}
if [ -n "${node}" ]; then
shift
nodeName=$(kubectl get node ${node} -o template --template='{{index .metadata.labels "kubernetes.io/hostname"}}') || exit 1
nodeSelector='"nodeSelector": { "kubernetes.io/hostname": "'${nodeName:?}'" },'
podName=${USER+${USER}-}sudo-${node}
else
nodeSelector=""
podName=${USER+${USER}-}sudo
@kainlite
kainlite / grpc.proto
Last active June 23, 2019 20:26
grpc
syntax = "proto3";
service PingService {
rpc Ping (PingRequest) returns (PingResponse);
}
message PingRequest {
string data = 1;
}
@kainlite
kainlite / client.go
Last active June 23, 2019 20:29
snippet
package main
import (
"context"
"log"
"os"
"time"
pb "github.com/kainlite/grpc-ping/ping"
"google.golang.org/grpc"
@kainlite
kainlite / server.go
Last active June 23, 2019 20:30
snippet
package main
import (
"context"
"log"
"net"
pb "github.com/kainlite/grpc-ping/ping"
"google.golang.org/grpc"
)
@kainlite
kainlite / snippet.sh
Created June 23, 2019 20:33
snippet.sh
protoc -I ping/ ping/ping.proto --go_out=plugins=grpc:ping
$ ping localhost -c 4
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.145 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.152 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.154 ms
64 bytes from localhost (::1): icmp_seq=4 ttl=64 time=0.141 ms
--- localhost ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3144ms
rtt min/avg/max/mdev = 0.141/0.148/0.154/0.005 ms
$ go run ping_client/main.go
2019/06/23 18:01:02 8 characters roundtrip to (localhost:50000): seq=0 time=1.941841ms
2019/06/23 18:01:03 8 characters roundtrip to (localhost:50000): seq=1 time=420.992µs
2019/06/23 18:01:04 8 characters roundtrip to (localhost:50000): seq=2 time=401.115µs
2019/06/23 18:01:05 8 characters roundtrip to (localhost:50000): seq=3 time=428.467µs
2019/06/23 18:01:06 8 characters roundtrip to (localhost:50000): seq=4 time=374.057µs
$ go run ping_server/main.go
2019/06/23 18:01:02 Received: 00
2019/06/23 18:01:03 Received: 00
2019/06/23 18:01:04 Received: 00
2019/06/23 18:01:05 Received: 00
2019/06/23 18:01:06 Received: 00
├── account.json
├── LICENSE
├── main.tf
├── module
│   ├── main.tf
│   ├── outputs.tf
│   └── variables.tf
├── README.md
└── terraform.tfvars