Skip to content

Instantly share code, notes, and snippets.

@achoimet
achoimet / journal.json
Created August 10, 2018 15:24
journal.json chaos toolkit
{
"chaoslib-version": "0.20.0",
"platform": "Windows-10-10.0.14393-SP0",
"node": "XXXXXXXXX",
"experiment": {
"version": "0.1.0",
"title": "Stopping a given EC2 instance",
"description": "Stopping a given EC2 instance",
"tags": [],
"steady-state-hypothesis": {
@achoimet
achoimet / authentication.go
Created May 10, 2020 19:19
Kubernetes AWS authentication in go
package k8sAuth
import (
"flag"
"fmt"
"github.com/aws/aws-sdk-go/aws/session"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
func main() {
// Subcommands
aws := flag.NewFlagSet("aws", flag.ExitOnError)
inCluster := flag.NewFlagSet("inCluster", flag.ExitOnError)
outCluster := flag.NewFlagSet("outCluster", flag.ExitOnError)
// aws subcommand flag pointers
clusterName := aws.String("clusterName", "", "EKS Cluster name. (Required)")
clusterUrl := aws.String("clusterUrl", "", "EKS Cluster url. (Required)")
roleArn := aws.String("roleArn", "", "EKS Role to assume. (Required)")
@achoimet
achoimet / create.go
Created May 10, 2020 19:29
create deployment in go
func createDeployment(clientAppsV1 typedappsv1.AppsV1Interface) error {
deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: appName,
Labels: map[string]string{
"app": appName,
},
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32Ptr(1),
package main
import (
"context"
"fmt"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/fake"
testingKube "k8s.io/client-go/testing"
deployment := &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": map[string]interface{}{
"name": "demo-deployment",
},
"spec": map[string]interface{}{
"replicas": 2,
"selector": map[string]interface{}{