Skip to content

Instantly share code, notes, and snippets.

View zxkane's full-sized avatar

Mengxin Zhu zxkane

View GitHub Profile
@zxkane
zxkane / pilipa:dev.yaml
Last active October 12, 2018 05:59
custom dev roles in k8s(no secrets)
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
labels:
kubernetes.io/bootstrapping: rbac-defaults
name: pilipa:dev
rules:
- apiGroups:
@zxkane
zxkane / nginx-ingress.conf
Created September 27, 2018 11:05
nginx ingress log configuration sample of aliyun log service, only collect json format log in stdout of docker
{
"inputs": [
{
"detail": {
"ExcludeLabel": {},
"IncludeEnv": {
"app": "nginx-ingress"
},
"IncludeLabel": {},
"Stderr": false
@zxkane
zxkane / image-request-stalled-in-chrome.har
Created December 10, 2018 08:00
image requests stuck on stalled status for 18s
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [],
"entries": [
{
@zxkane
zxkane / run-with-auth.sh
Created January 26, 2019 14:07
socks proxy
docker run -d --restart always --name dingtalk-proxy -p 55555:1080 -e PROXY_USER=user -e PROXY_PASSWORD=passw0rd serjs/go-socks5-proxy
@zxkane
zxkane / route53.sh
Created September 18, 2019 10:12
The private hosted route of Route53 associates with the VPC in another account
export AWS_DEFAULT_PROFILE=account_a(has route53)
aws route53 create-vpc-association-authorization --hosted-zone-id zoneid --vpc VPCRegion=ap-southeast-1,VPCId=vpc-xxxx
export AWS_DEFAULT_PROFILE=account_b(has vpc-xxxx)
aws route53 associate-vpc-with-hosted-zone --hosted-zone-id zoneid --vpc VPCRegion=ap-southeast-1,VPCId=vpc-xxxx
@zxkane
zxkane / user-date.sh
Last active October 29, 2019 08:02
Test AWS S3 download performance in Ubuntu LTS 18.04
#!/bin/bash -x
add-apt-repository ppa:plushuang-tw/uget-stable -y
apt install aria2 parallel iotop tmux python3-pip -y
pip3 install awscli --upgrade --user
export AWS_DEFAULT_REGION=ap-northeast-1
SECONDS=0
seq 1 5 | parallel --will-cite -j 5 'url=$(aws s3 presign s3://<your bucket>/test-files/file-{});aria2c --file-allocation=none -c -x 4 -s 4 -d /dev -o null $url'
duration=$SECONDS
RESULT=result-$(curl http://169.254.169.254/latest/meta-data/instance-type)-$(curl http://169.254.169.254/latest/meta-data/instance-id)-seconds-${duration}
touch /tmp/$RESULT
@zxkane
zxkane / .zshrc
Created November 12, 2019 07:17
aws shortcuts
# aws ec2 alias or quick functions
alias ec2-instance-list="aws ec2 describe-instances --output table --query 'Reservations[*].Instances[*].{Instance:InstanceId,Type:InstanceType,AZ:Placement.AvailabilityZone,Name:Tags[?Key==\`Name\`]|[0].Value,Dns:NetworkInterfaces[0].Association.PublicDnsName,State:State.Name}' --filters 'Name=instance-state-code,Values=16'"
alias ec2-terminate-instance="aws ec2 terminate-instances --instance-ids"
function _ec2-launch {
templateName='my-instances-launch-template'
amiid="$1"
if [ -z "$amiid" ]; then
echo 'AMI is missing'
return
@zxkane
zxkane / cluster.yml
Last active May 20, 2020 02:56
Create a EKS cluster with IAM for service account
---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: cluster-3
region: cn-northwest-1
nodeGroups:
- name: ng2-private
@zxkane
zxkane / route53.delete-records.json
Last active February 14, 2020 04:08
Create/Update/Delete DNS records in Route 53 hosted zone in CLI
{
"Comment": "Delete CNAME record in route 53 hosted zone",
"Changes": [
{
"Action": "DELETE",
"ResourceRecordSet": {
"Name": "pypi.mirrors.testtest.vme360.com",
"Type": "CNAME",
"TTL": 300,
"ResourceRecords": [
@zxkane
zxkane / policy.json
Created March 12, 2020 14:59
readonly permissions for some AWS services
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1584020444106",
"Action": [
"serverlessrepo:GetApplication",
"serverlessrepo:GetApplicationPolicy",
"serverlessrepo:GetCloudFormationTemplate",
"serverlessrepo:ListApplicationDependencies",