Skip to content

Instantly share code, notes, and snippets.

View neilkuan's full-sized avatar
🎯
Focusing

Neil Kuan neilkuan

🎯
Focusing
View GitHub Profile
#!/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)
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"}}'
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[];
}
#!/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
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: __API_NAME__
namespace: __NAMESPACE__
spec:
maxReplicas: 2
minReplicas: 1
scaleTargetRef:
apiVersion: extensions/v1beta1
@neilkuan
neilkuan / example-register-docker-runner.sh
Last active November 24, 2020 02:34
Example Register Docker Runner Shell Script .
#!/bin/bash
RUNNER_TOKEN=$1
# Register
docker run -it --rm -v /root/gitlab-runner-sit:/etc/gitlab-runner gitlab/gitlab-runner:alpine \
register --non-interactive --url https://gitlab.com \
--registration-token ${RUNNER_TOKEN} --docker-pull-policy if-not-present \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock --executor docker \
--docker-volumes /root/.m2:/root/.m2 \
--docker-image alpine:latest --description "Docker Runner" --docker-privileged \
@neilkuan
neilkuan / send-publickey-connect.sh
Last active May 9, 2022 09:55
send public key to connect ec2
#!/bin/bash
instanceId=$1
pubkey="$HOME/.ssh/id_rsa.pub"
sshUser='ec2-user'
az=$(aws ec2 describe-instances --instance-id ${instanceId} --query 'Reservations[0].Instances[0].Placement.AvailabilityZone' --output text)
echo "sending public key to ${instanceId}"
aws ec2-instance-connect send-ssh-public-key --instance-id ${instanceId} --instance-os-user ${sshUser} \
@neilkuan
neilkuan / init-super-user.sh
Created September 29, 2020 02:28
Use AWS CLI to create Super User , so fast !!!
#!/bin/bash
set pipefail
if [ $# != 2 ]
then
echo "Please give username and password \n ./init-super-user.sh tempuser 2wsx#EDCv ..."
exit 1
fi
USER_NAME=$1
#!/bin/bash
TMPFILE=/tmp/u53tempfile
TMPFILE_URI="file://$TMPFILE"
AWS=/usr/local/bin/aws
function try {
eval $*
if [ $? -ne 0 ]; then
echo "Error while evaluating \"$*\", exiting..."
version: "3.7"
services:
nexus:
image: "sonatype/nexus3:3.19.1"
container_name: "nexus"
restart: always
ports:
- "8081:8081"
- "5000:5000"
volumes: