Skip to content

Instantly share code, notes, and snippets.

View gavinzhou's full-sized avatar
🏠
Working from home

Gavin Zhou gavinzhou

🏠
Working from home
View GitHub Profile
@gavinzhou
gavinzhou / playbook-to-migrate-to-imdsv2.yml
Created April 11, 2024 09:42 — forked from suneshgovind/playbook-to-migrate-to-imdsv2.yml
Ansible playbook to automate migration of AWS EC2 instances to Instance Metadata Service version 2 (IMDSv2)
---
- name: To enable IMDSv2 in AWS EC2 instances
hosts: localhost
vars:
regions: ["eu-north-1", "ap-south-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-2", "ap-northeast-1", "sa-east-1", "ca-central-1", "ap-southeast-1", "ap-southeast-2", "eu-central-1", "us-east-1", "us-east-2", "us-west-1", "us-west-2"]
shell_file: "modify_instance_metadata_options.sh"
tasks:
- name: get instance info
local_action:
git clone --mirror https://bitbucket.org/aiida_team/aiida_core.git
cd aiida_core.git
git remote set-url --push origin git@github.com:giovannipizzi/aiida_core_test.git
git push --mirror
BAD_INSTANCE=[your node name from kubectl get nodes]
kubectl cordon $BAD_INSTANCE
kubectl drain $BAD_INSTANCE
gcloud compute instances describe --format='value[](metadata.items.created-by)' $BAD_INSTANCE
gcloud compute instance-groups managed delete-instances --instances=$BAD_INSTANCE --zone=[from describe output] [grp from describe output]
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
b_release -cs) \
le"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker ps
sudo chgrp gavin /var/run/docker.sock
@gavinzhou
gavinzhou / multiple-gcloud
Created March 18, 2019 01:54
How to use multiple service accounts with gcloud
$ gcloud config configurations create my-project1-config
$ gcloud config configurations activate my-project1-config
$ gcloud auth login # or activate-service-account
$ gcloud config set project project1 # and any other configuration you need to do
$ gcloud config configurations create my-project2-config
$ gcloud config configurations activate my-project2-config
$ gcloud auth login # or activate-service-account
$ gcloud config set project project2 # and any other configuration you need to do
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
now run the kube-proxy
kubectl proxy &
Starting to serve on 127.0.0.1:8001
save the ID to delete it later on :)
3. find your name-space that decided no to be deleted :) for us it will be cattle-system
kubectl get ns
cattle-system Terminating 1d
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-deployment
labels:
app: prometheus
purpose: example
spec:
replicas: 2
selector:

Keybase proof

I hereby claim:

  • I am gavinzhou on github.
  • I am gavinzhou (https://keybase.io/gavinzhou) on keybase.
  • I have a public key whose fingerprint is 7734 8B84 AADF 1D51 2051 B1CE 514D 21A6 26B7 AD0F

To claim this, I am signing this object:

package v1
import (
"log"
"net/http"
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
"github.com/gavinzhou/hello-gin/models"
"github.com/gavinzhou/hello-gin/pkg/e"
package models
import (
"github.com/jinzhu/gorm"
"time"
)
type Article struct {
Model