Skip to content

Instantly share code, notes, and snippets.

View Kailashcj's full-sized avatar

Kailash Chander Kailashcj

  • Bangalore
View GitHub Profile
func main() {
nums := []{13,7,4,9}
quicksort(nums, 0, len(nums)-1)
}
func quicksort(arr []int, lo,hi int) {
if len(arr) < 2 {return}
if lo < hi {
p := partition(arr,lo,hi)
quicksort(arr,lo,p-1)
// IMPORTANT: THIS IS NOT COMPLETE CODE. THIS IS JUST A SAMPLE TO HELP YOU WRITE YOUR OWN UPGRADE AUTOMATION
/*
What should you include in your code:
1. create an AWS session and k8s kubeconfig context. These variables can be taken as user input
2. disable cluster autoscaler by setting the replica count to 0
3. create AWS autoscaling object. This will be required to query the existing ASG and perform
required modifications for the upgrade process
4. create a main upgrade job which will trigger the upgrade by performing following actions:
- get a list of all ASG in your cluster
@Kailashcj
Kailashcj / awsmsad_modifydefaultsgrules.yml
Last active June 18, 2019 05:05
awsmsad_modifydefaultsgrules.yml
AWSTemplateFormatVersion: 2010-09-09
Description : >-
This template deploys AWS Directory Services for Microsoft AD
and changes the ingress rules of the default security group
Parameters:
VpcId:
Description: Name of the VPC
Type: AWS::EC2::VPC::Id
VpcCIDR:
Description: VpcCIDR block to allow specific traffic from/to Vpc range
AWSTemplateFormatVersion: '2010-09-09'
Description : >-
This template deploys a VPC and creates following resources in the VPC;
1 Public and 1 Private Subnet in a single availabilty zone
1 Internet gateway
1 NATGateway
1 Public RouteTable and 1 Private RouteTable
Parameters:
EnvironmentName:
Type: String
AWSTemplateFormatVersion: '2010-09-09'
Description: >-
This template deploys a new VPC and creates a new subnet and custom route table.
It uses a cloudformation custom resource which invokes a lambda function to
set the custom route table as the defaul MAIN route table.
Lambda function is using boto3(python sdk) function 'replace_route_table_association(**kwargs)' to replace the main routetable.
replace_route_table_association(**kwargs) function itself needs two parameters to make this change.
parameter1 # routetableassociationId of the existing main routetable. This is identified by iterating each route table in VPC
parameter2 # routetableId of the custom routetable. This is a reference to the new route table resource created in this template.
Parameters:
#!usr/bin/python
"""
Sample python script to migrate documents from mongodb to apache couchdb database.
This script reads a document from mongodb and writes it to couchdb database.
**Script does not support the use case for 'documents with attachments'
"""
import json
from argparse import ArgumentParser
import requests

mongo2couch.py

mongo2couch.py is a sample python script to migrate documents from mongodb to apache couchdb database. This script reads a document from mongodb and writes it to couchdb database. Script does not support the use case for 'documents with attachments'

For details on migration approach, refer: http://tiny.cc/mep73y

How to use?