Skip to content

Instantly share code, notes, and snippets.

View tristanlins's full-sized avatar

Tristan Lins tristanlins

View GitHub Profile
@tristanlins
tristanlins / .gitlab-ci.yml
Last active January 19, 2020 13:32
Medium | gitlab ci deploy
deploy:
image:
name: bitnami/kubectl:latest
entrypoint: [""]
stage: deploy
dependencies: []
script:
# Update the deployment
- kubectl patch deployment my-app -p '{"spec":{"template":{"metadata":{"labels":{"commitRef":"'sha-$CI_COMMIT_SHORT_SHA'"}}}}}'
# If you want to wait for the rollout
@tristanlins
tristanlins / kubectl.sh
Last active January 19, 2020 13:28
Medium | Test kubernetes config
$ KUBECONFIG=/path/to/config.yml kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
my-app 1/1 1 1 1s
@tristanlins
tristanlins / config.yml
Created January 19, 2020 13:25
Medium | Kubernetes config.yml
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: EdAGjzRzleL2JladlfiP2kItNJHPg4aZYvFE0XB9Z7brN60e0rks6eYKO/oEyT5vTDgjtuZfPuAAh7lyJgFaLT8QljoA7RZb9fc0KGXsJcvNlH9075Q6QpMiOjQ2PQN4MZO8Z3729yHhqsgRsaaN//9tU2+TPDk81fYeBF2eeUQ=
server: https://my-k8s.example.com:6443
name: default
contexts:
- context:
cluster: default
namespace: my-namespace
@tristanlins
tristanlins / kubectl.sh
Created January 19, 2020 13:21
Medium | decode service account token
$ echo 'uz8MTKfySDNSDvVo+rYCUQh6qk5UM8/+Efoqk54CMs/0rtBsFyYAotHUTeckqHPF6OXO/WLqiftJXftXAzikYw==' | base64 -d
PzjCMXyy34MrTRmUEgFxzwNmVkqTanizdxEWPxupTjKuxgNU
@tristanlins
tristanlins / kubectl.sh
Created January 19, 2020 13:15
Medium | get secret credentials
$ kubectl get secret gitlab-token-1cdd47 -o yaml
apiVersion: v1
data:
ca.crt: EdAGjzRzleL2JladlfiP2kItNJHPg4aZYvFE0XB9Z7brN60e0rks6eYKO/oEyT5vTDgjtuZfPuAAh7lyJgFaLT8QljoA7RZb9fc0KGXsJcvNlH9075Q6QpMiOjQ2PQN4MZO8Z3729yHhqsgRsaaN//9tU2+TPDk81fYeBF2eeUQ=
...
token: uz8MTKfySDNSDvVo+rYCUQh6qk5UM8/+Efoqk54CMs/0rtBsFyYAotHUTeckqHPF6OXO/WLqiftJXftXAzikYw==
kind: Secret
metadata:
name: gitlab-token-1cdd47
type: kubernetes.io/service-account-token
@tristanlins
tristanlins / kubectl.sh
Created January 19, 2020 12:51
Medium | get gitlab serviceaccount secret
$ kubectl get sa gitlab -o yaml
apiVersion: v1
kind: ServiceAccount
metadata:
...
name: gitlab
...
secrets:
- name: gitlab-token-1cdd47
@tristanlins
tristanlins / rbac.yml
Created January 19, 2020 12:45
Medium | Gitlab ServiceAccount with RBAC
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: pod-manager
rules:
@tristanlins
tristanlins / deployment.yml
Created January 19, 2020 12:12
Medium | Simple deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: my-app
name: my-app
spec:
replicas: 1
strategy:
type: Recreate
@tristanlins
tristanlins / extension.kt
Created April 24, 2019 13:58
[kotlin] Create logger using extension function
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import kotlin.reflect.KClass
fun <T : Any> KClass<T>.logger(): Logger {
return LoggerFactory.getLogger(this.java)
}
@tristanlins
tristanlins / logger.kt
Last active April 24, 2019 13:58
[kotlin] Create logger using LoggerFactory
val LOG = LoggerFactory.getLogger(MyClass::class.java)