This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Stay-Available ($seconds) { | |
while ($True) { Start-Sleep -Seconds $seconds ; $(New-Object -ComObject 'Wscript.Shell').sendkeys('{SCROLLLOCK}') } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The problem is that if you have only one definition of a cluster, context or user in the `~/.kube/config` file | |
and you delete one of them then `kubectl` will set deleted type to `null` instead of `[]`. | |
Then if you try to `update-kubeconfig` using aws cli command you will see an error: | |
* if `contexts: null`: Tried to insert into contexts,which is a <class 'NoneType'> not a <class 'list'> | |
* if `users: null`: Tried to insert into users,which is a <class 'NoneType'> not a <class 'list'> | |
* if `clusters: null`: 'NoneType' object is not iterable | |
Simple workaround for above cases is to replace all `null` with `[]` then run aws cli `update-kubeconfig` command, like this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Issue: | |
# terragrunt destroy | |
Error: Delete "http://localhost/api/v1/namespaces/kube-system/configmaps/aws-auth": dial tcp 127.0.0.1:80: connect: connection refused | |
Fix: | |
# terragrunt state rm module.eks.kubernetes_config_map.aws_auth | |
Removed module.eks.kubernetes_config_map.aws_auth[0] | |
Successfully removed 1 resource instance(s). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker pull k8s.gcr.io/pause:3.1; docker tag k8s.gcr.io/pause:3.1 amazon/amazon-ecs-pause:0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ec2 describe-subnets --filter Name=vpc-id,Values=vpc-1234567890 --query 'Subnets[?MapPublicIpOnLaunch==`false`].SubnetId' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWS_PROFILE=${AWS_PROFILE:-default} | |
EKS_CLUSTER_NAME= | |
KUBECONFIG=/root/.kube/config | |
TF_STATE=$(terragrunt output -json config_map_aws_auth | jq '.[].metadata[]') | |
CONFIG_MAP_NAMESPACE=$(echo "${TF_STATE}" | jq -r '.namespace') | |
CONFIG_MAP_NAME=$(echo "${TF_STATE}" | jq -r '.name') | |
curl -k \ | |
-H "Authorization: Bearer $(AWS_PROFILE=${AWS_PROFILE} aws eks get-token --cluster-name ${EKS_CLUSTER_NAME} | jq -r .status.token)" \ | |
-H 'Accept: application/json' \ | |
$(yq e '.clusters[].cluster.server' ${KUBECONFIG})/api/v1/namespaces/${CONFIG_MAP_NAMESPACE}/configmaps/${CONFIG_MAP_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws es list-domain-names | jq -r .DomainNames[].DomainName | while read dn; do echo -ne "$dn - " ; curl -sk https://$(aws es describe-elasticsearch-domain --domain-name ${dn} | jq -r .DomainStatus.Endpoints.vpc)/_cluster/health | jq .status ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
awsRegion=$1 | |
instanceType=$2 | |
url=https://banzaicloud.com/cloudinfo/api/v1/providers/amazon/services/compute/regions/${awsRegion}/products | |
curl -ksLX GET ${url} | jq ".products[] | select(.type | contains(\"${instanceType}\")) | .onDemandPrice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ecr describe-repositories | jq -r '.repositories[].repositoryName' | sort | while read repository; do | |
totalSizeOfUntagged=0 | |
while read imageSizeInBytes; do | |
totalSizeOfUntagged=$((totalSizeOfUntagged + imageSizeInBytes)) | |
done < <(aws ecr describe-images --repository-name ${repository} --filter tagStatus=UNTAGGED | jq -r '.imageDetails[].imageSizeInBytes') | |
if [[ ${totalSizeOfUntagged} -gt 0 ]]; then | |
echo -ne "${repository} - " | |
echo ${totalSizeOfUntagged} | awk '{ print $1/1024/1024 " MB" }' | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
totalNumberOfUntagged=0 | |
while read repository; do | |
numberOfUntagged=$(aws ecr list-images --repository-name ${repository} --filter tagStatus=UNTAGGED --query 'imageIds[*]' | jq -r '.[].imageDigest' | wc -l) | |
if [[ ${numberOfUntagged} -gt 0 ]]; then | |
echo "${repository} - ${numberOfUntagged}" | |
totalNumberOfUntagged=$((totalNumberOfUntagged + numberOfUntagged)) | |
fi | |
done < <(aws ecr describe-repositories | jq -r '.repositories[].repositoryName' | sort) | |
echo ${totalNumberOfUntagged} |
NewerOlder