Skip to content

Instantly share code, notes, and snippets.

View neilkuan's full-sized avatar
🎯
Focusing

Neil Kuan neilkuan

🎯
Focusing
View GitHub Profile
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: __API_NAME__
namespace: __NAMESPACE__
spec:
maxReplicas: 2
minReplicas: 1
scaleTargetRef:
apiVersion: extensions/v1beta1
#!/bin/bash
export AWS_DEFAULT_REGION=ap-northeast-1
aws logs describe-log-streams --log-group-name fluentbit-cloudwatch --query 'logStreams[*].logStreamName' --output table \
| awk '{print $2}' | grep ^$2 \
| while read x; do echo "deleting $x" ; aws logs delete-log-stream --log-group-name $1 --log-stream-name $x; done
import * as ec2 from '@aws-cdk/aws-ec2';
import * as ecs from '@aws-cdk/aws-ecs';
//import * as ecspat from '@aws-cdk/aws-ecs-patterns';
import * as iam from '@aws-cdk/aws-iam';
import { App, Construct, Stack, StackProps, CfnOutput } from '@aws-cdk/core';
export interface runnerMyStackProps extends StackProps{
gitlabRegistrationToken: string;
tagLists?: string[];
}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
namespace: vnins
name: ingress-gateway
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig":{"Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
#!/bin/bash
AWS_PROFILE=<yourprofile-name>
instanceId=$1
pubkey="$HOME/.ssh/id_rsa.pub"
sshUser='ec2-user'
az=$(aws ec2 describe-instances --instance-id ${instanceId} --region ap-northeast-1 --query 'Reservations[0].Instances[0].Placement.AvailabilityZone' --output text)
privateIp=$(aws ec2 describe-instances --instance-id ${instanceId} --region ap-northeast-1 --query 'Reservations[0].Instances[0].PrivateIpAddress' --output text)
cd ~/
sudo yum install ruby -y
sudo amazon-linux-extras install epel -y > /dev/null 2>&1
sudo yum install figlet -y
echo "ruby version"
ruby --version
if [ -f ~/master.zip ]
then
echo "lolcat master.zip already download"
@neilkuan
neilkuan / demo-terraform-cloud
Created December 22, 2020 09:58
ORG_NAME_ON_TERRAFORM_CLOUD
terraform {
backend "remote" {
organization = "ORG_NAME_ON_TERRAFORM_CLOUD"
workspaces {
name = "WORKSPACES_NAME_ON_TERRAFORM_CLPUD"
}
}
}
provider "aws" {
# get daemonset image name.
$ kubectl get ds ${DS_NAME} -o json -n kube-system | jq -r .spec.template.spec.containers[].image | sort -u
# get specify pod image name.
$ kubectl get pod -n kube-system | grep ${Pod_Name} | awk '{print $1}' | while read x; do kubectl get pod $x -o json -n kube-system | jq -r .spec.containers[].image; done
# force delete pod
$ kubectl delete pods ${Pod_Name} --grace-period=0 --force
# get all namespace pod image name
@neilkuan
neilkuan / install-docker.md
Last active February 10, 2021 23:30 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@neilkuan
neilkuan / express-quick-start.md
Last active February 15, 2021 02:54
express-quick-start README.md

Create Dir express-quick-start

$ mkdir express-quick-start

$ cd express-quick-start

# init project name foo
$ npx express-generator@4 foo
---
npx: 10 安裝成功,花費 2.298 秒