Skip to content

Instantly share code, notes, and snippets.

View zxkane's full-sized avatar

Meng Xin Zhu zxkane

View GitHub Profile
@zxkane
zxkane / setup.sh
Last active June 13, 2022 15:07
use kind to debug gitops flux locally
# set kubeconfig for your kind cluster
export KUBECONFIG=$HOME/.kube/kind
# create kind cluster
kind create cluster --name gitops
# provisioning flux
flux install --components-extra=image-reflector-controller,image-automation-controller --export > gotk-components.yaml
cat <<EOF > kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
@zxkane
zxkane / post-publish.sh
Last active February 8, 2022 10:37
Those scripts are deprecated, see e2e example for detail, https://github.com/aws-samples/cdk-bootstrapless-synthesizer/tree/main/sample-pipeline for detail. use CDK customize synthesizer to publish assets, https://github.com/aws-samples/cdk-bootstrapless-synthesizer.
#!/bin/bash
set -euxo pipefail
publish_s3_assets() {
local name=$1
local prefix=$2
aws s3 ls s3://$name/$prefix --recursive | awk '{print $4}' | xargs -I {} -n 1 aws s3api put-object-acl --acl public-read --bucket $name --key {}
}
@zxkane
zxkane / push-helm-chart-to-all-ecr-regions.sh
Created September 27, 2021 09:42
push helm chart to all ecr regions
#!/bin/bash -xe
create_repo() {
local name=$1
local region=$2
# create ecr repo
aws ecr create-repository --region $region --repository-name "$name" --image-tag-mutability IMMUTABLE --image-scanning-configuration scanOnPush=true --encryption-configuration encryptionType=AES256 2>/dev/null
# set repo permission
@zxkane
zxkane / sagemaker-endpoint-invoke.py
Created August 26, 2021 04:32
invoke sagemaker endpoints without AWS SDK
# Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# This file is licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the specific
@zxkane
zxkane / diff.py
Last active October 24, 2022 07:40
diff two dataset by pandas
import pandas as pd
import os
import glob
import logging
pandas_etl_data_dir = '/etl-diff/panda-output'
spark_etl_data_dir = '/etl-diff/spark-output'
def get_logger(name):
logger = logging.getLogger(name)
@zxkane
zxkane / gitops-prod.yml
Last active March 1, 2022 07:18
eksctl-collections
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: gitops-cluster-prod
region: ap-southeast-1
version: '1.21'
karpenter:
version: 0.4.3
createServiceAccount: true
managedNodeGroups:
@zxkane
zxkane / push-repo-to-all-ecr-regions.sh
Last active April 26, 2021 09:55
Push a container image to all ECR regions(create the repo if necessary)
#!/bin/bash -xe
create_repo() {
local name=$1
local region=$2
# create ecr repo
aws ecr create-repository --region $region --repository-name "$name" --image-tag-mutability IMMUTABLE --image-scanning-configuration scanOnPush=true --encryption-configuration encryptionType=AES256 2>/dev/null
# set repo permission
# Amazon Neptune version 4 signing example (version v2)
# The following script requires python 3.6+
# (sudo yum install python36 python36-virtualenv python36-pip)
# => the reason is that we're using urllib.parse() to manually encode URL
# parameters: the problem here is that SIGV4 encoding requires whitespaces
# to be encoded as %20 rather than not or using '+', as done by previous/
# default versions of the library.
@zxkane
zxkane / snippet.ts
Created March 5, 2021 15:24
how set cfn condition to CDK resources
const standardPartitionCondition = new CfnCondition(this, 'IsStandardPartition', {
expression: Fn.conditionEquals(Aws.PARTITION, 'aws'),
});
const dbUser = 'dashboard';
const docDBCluster = new DatabaseCluster(this, 'DashboardDatabase', {
masterUser: {
username: dbUser,
},
storageEncrypted: true,
@zxkane
zxkane / .gitigore
Last active January 13, 2022 14:46
purge obsolete resources after deleting nexus3 stack created by solution https://github.com/aws-samples/nexus-oss-on-aws
local-empty-dir/