Skip to content

Instantly share code, notes, and snippets.

View akshedu's full-sized avatar

Akshansh Gupta akshedu

  • Podkite
  • Mumbai
View GitHub Profile
@akshedu
akshedu / update.sh
Created June 21, 2021 03:48
Cluster update
#!/bin/sh
echo "Apply update cluster"
kops update cluster --yes
echo "Export kubectl config"
kops export kubecfg --admin
echo "Dry run rolling update"
kops rolling-update cluster
@akshedu
akshedu / values.yaml
Created June 21, 2021 03:44
Cluster config values
clusterName: abcd.k8s.local
subnetCIDRb:
subnetCIDRa:
UtilitysubnetCIDRb:
UtilitysubnetCIDRa:
egressNAT:
APImaxSize: 2
APIminSize: 1
ModelmaxSize: 1
ModelminSize: 1
externalPolicies:
node:
kubernetesVersion: 1.19.3
awsRegion:
networkCIDR:
networkID:
@akshedu
akshedu / ig.ipl
Created June 21, 2021 03:36
Instance groups template
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
labels:
kops.k8s.io/cluster: {{.clusterName}}
name: master-{{.awsRegion}}b
spec:
image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20201026
machineType: t2.medium
maxSize: 1
@akshedu
akshedu / cluster.ipl
Created June 21, 2021 03:32
Cluster template
apiVersion: kops.k8s.io/v1alpha2
kind: Cluster
metadata:
name: {{.clusterName}}
spec:
clusterAutoscaler:
enabled: true
skipNodesWithLocalStorage: false
skipNodesWithSystemPods: true
newPodScaleUpDelay: "60s"
@akshedu
akshedu / dryrun.sh
Created June 21, 2021 03:19
kops dryrun
#!/bin/sh
echo "Check if cluster config exists on S3"
if ! kops get cluster; then
echo "Create SSH Key"
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
echo "Create cluster config on S3"
kops create cluster --cloud aws --zones $AWS_ZONES
fi
@akshedu
akshedu / .gitlab-ci.yml
Last active June 21, 2021 03:17
CI/CD jobs which used to create and manage a cluster via kops
# Custom image with kops, kubectl and kustomize
image: 123456789123.dkr.ecr.ap-south-1.amazonaws.com/k8s:latest
stages:
- dryrun
- update
- roll
- addons
dryrun:
@akshedu
akshedu / .gitlab-ci.yml
Last active June 20, 2021 12:51
Create an image which can run k8s commands and push it to ECR
stages:
- build
build_k8s:
stage: build
when: manual
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ["/busybox/sh"]
script:
@akshedu
akshedu / Dockerfile
Last active June 20, 2021 12:46
Dockerfile to create an image which can run kops, kubectl and kustomize commands
# Use a builder layer while adding ecr-login to minimise the size of final image
FROM golang:alpine AS builder
RUN apk --no-cache add git && \
git clone https://github.com/awslabs/amazon-ecr-credential-helper /go/src/github.com/awslabs/amazon-ecr-credential-helper && \
go build -o /assets/docker-credential-ecr-login github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login
FROM alpine AS resource
COPY --from=builder /assets/docker-credential-ecr-login /usr/local/bin/docker-credential-ecr-login
# OpenSSH is required to create a ssh key while creating a new cluster

Keybase proof

I hereby claim:

  • I am akshedu on github.
  • I am akshedu (https://keybase.io/akshedu) on keybase.
  • I have a public key ASDmy--uZ1lCoHCwNM4BuguT8TsJ1JzE7WEQfcorQCJ6XQo

To claim this, I am signing this object: