Skip to content

Instantly share code, notes, and snippets.

View rimusz's full-sized avatar

Rimantas (Rimas) Mocevicius rimusz

View GitHub Profile
@rimusz
rimusz / gcrgc.sh
Created August 9, 2017 11:37 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@rimusz
rimusz / decrypt-secret.sh
Created August 1, 2017 13:05 — forked from nshttpd/decrypt-secret.sh
gcloud decrypt
#!/bin/bash
set -e
GCP_PROJECT="${GCP_PROJECT:-default}"
KMS_KEYRING="${KMS_KEYRING:-default}"
KMS_LOCATION="${KMS_LOCATION:-default}"
KMS_KEY="${KMS_KEY:-default}"
hash gcloud 2>/dev/null || { echo >&2 "gcloud command required to decrypt secrets."; exit 1; }
@rimusz
rimusz / encrypt-secret.sh
Last active August 1, 2017 13:06 — forked from nshttpd/encrypt-secret.sh
gcloud encrypt
#!/bin/bash
set -e
GCP_PROJECT="${GCP_PROJECT:-default}"
KMS_KEYRING="${KMS_KEYRING:-default}"
KMS_LOCATION="${KMS_LOCATION:-default}"
KMS_KEY="${KMS_KEY:-default}"
hash gcloud 2>/dev/null || { echo >&2 "gcloud command required to encrypt secrets."; exit 1; }
@rimusz
rimusz / run-conformance-test.sh
Last active July 25, 2017 20:29
Kubernetes conformance test
#!/usr/bin/env bash
set -euo pipefail
CONFORMANCE_REPO=${CONFORMANCE_REPO:-github.com/kubernetes/kubernetes}
CONFORMANCE_VERSION=${CONFORMANCE_VERSION:-v1.6.4}
KUBECLOUD_PROVIDER=${KUBECLOUD_PROVIDER:-aws}
KUBECONFIG=${KUBECONFIG:-/etc/kubernetes/kubeconfig}
usage() {
@rimusz
rimusz / gcb-kubernetes.yaml
Created May 30, 2017 22:58 — forked from Philmod/gcb-kubernetes.yaml
Deploy a new image from Google Cloud Container Builder to Kubernetes, by storing GKE credentials in GCS.
steps:
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
- name: 'gcr.io/cloud-builders/npm'
args: ['test']
- name: 'gcr.io/cloud-builders/docker'
args: ["build", "-t", "gcr.io/$PROJECT_ID/frontend:$REVISION_ID", "."]
- name: 'gcr.io/cloud-builders/docker'
args: ["push", "gcr.io/$PROJECT_ID/frontend:$REVISION_ID"]
- name: 'gcr.io/cloud-builders/gcloud'
@rimusz
rimusz / gitlab-runner.yaml
Created May 10, 2017 15:40 — forked from lsjostro/gitlab-runner.yaml
gitlab-runner k8s
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: gitlab-ci
namespace: gitlab
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
@rimusz
rimusz / pr.md
Created May 5, 2017 07:48 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@rimusz
rimusz / parse-tcpdump-udp-port-53.php
Created March 23, 2017 14:56 — forked from jtai/parse-tcpdump-udp-port-53.php
Quick and dirty script to parse output of /usr/sbin/tcpdump -vvv -s 0 -l port 53
<?php
// quick and dirty argument parsing
foreach ($argv as $arg) {
if ($arg == '-f') {
define('FOLLOW', true);
}
if ($arg == '-h') {
define('HISTOGRAM', true);
}
@rimusz
rimusz / kube-rotate.sh
Created October 26, 2016 14:13 — forked from mgoodness/kube-rotate.sh
Bash script for draining & terminating Kubernetes nodes
#!/usr/bin/env bash
k8s_node="$1"
kubectl drain --force --ignore-daemonsets --delete-local-data ${k8s_node}
if [[ $? -eq 0 ]]; then
instance_id=$(aws ec2 describe-instances --out=text\
--filters Name=network-interface.private-dns-name,Values=${k8s_node} \
--query 'Reservations[0].Instances[0].{InstanceID:InstanceId}')
@rimusz
rimusz / README.md
Created October 14, 2016 08:32 — forked from adambom/README.md
Backup Kubernetes Cluster State

Run this in order to backup all you k8s cluster data. It will be saved in a folder bkp. To restore the cluster, you can run kubectl apply -f bkp.

Please note: this recovers all resources correctly, including dynamically generated PV's. However, it will not recover ELB endpoints. You will need to update any DNS entries manually, and manually remove the old ELB's.

Please note: This has not been tested with all resource types. Supported resource types include:

  • services
  • replicationcontrollers
  • secrets
  • deployments
  • horizontal pod autoscalers