Some bits and pieces of useful commands for working with k8s
This file contains hidden or 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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGEX="^prefix-" | |
| WAIT=true | |
| stacks=$(aws cloudformation describe-stacks --query Stacks[].StackName --output=text) | |
| for stack in $stacks; do | |
| if [[ $stack =~ $REGEX ]]; then |
This file contains hidden or 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
| for CLUSTER in $(aws ecs list-clusters --output=text | awk '{print $2}') | |
| do | |
| for SERVICE in $(aws ecs list-services --cluster=$CLUSTER --output text | awk '{print $2}') | |
| do | |
| for TASK in $(aws ecs list-tasks --cluster=$CLUSTER --service-name=$SERVICE --output=text | awk '{print $2}') | |
| do | |
| aws ecs describe-tasks --cluster=$CLUSTER --tasks=$TASK \ | |
| --query 'tasks[*].[taskArn, createdAt]' --output=text | \ | |
| awk -v end='2021-12-21' '{print $1}' | |
| done |
This file contains hidden or 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
| import boto3 | |
| dynamodb = boto3.resource('dynamodb', 'region-name') | |
| table = dynamodb.Table('table-name') | |
| scan = table.scan( | |
| ProjectionExpression='#k', | |
| ExpressionAttributeNames={ | |
| '#k': 'name' | |
| } |
service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval(in minutes)service.beta.kubernetes.io/aws-load-balancer-access-log-enabled(true|false)service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-nameservice.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefixservice.beta.kubernetes.io/aws-load-balancer-additional-resource-tags(comma-separated list of key=value)service.beta.kubernetes.io/aws-load-balancer-backend-protocol(http|https|ssl|tcp)service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled(true|false)
This is a quick recipe for deploying cert-manager and nginx-ingress on GKE to obtain SSL certificates from Lets Encrypt. Whilst this recipe is designed for Google Cloud Platform, it can easily be adapted for other cloud platforms.
We'll begin with a Kubernetes cluster, and we'll obtain authentication credentials.
gcloud container clusters get-credentials my-test-app
kubectl config current-context
kubectl get nodes
This file contains hidden or 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
| kind: Service | |
| apiVersion: v1 | |
| metadata: | |
| name: example-final-elb | |
| spec: | |
| ports: | |
| - port: 80 | |
| targetPort: 9376 | |
| selector: | |
| app: source-ip |
This file contains hidden or 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
| kind: Service | |
| apiVersion: v1 | |
| metadata: | |
| name: my-mediaiq-service | |
| spec: | |
| ports: | |
| - port: 8765 | |
| targetPort: 9376 | |
| selector: | |
| app: source-ip |
This file contains hidden or 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
| apiVersion: extensions/v1beta1 | |
| kind: Deployment | |
| metadata: | |
| name: nginx-ingress-controller | |
| spec: | |
| replicas: 1 | |
| revisionHistoryLimit: 3 | |
| template: | |
| metadata: | |
| labels: |
This file contains hidden or 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
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: nginx-ingress | |
| spec: | |
| type: LoadBalancer | |
| ports: | |
| - port: 80 | |
| name: http | |
| - port: 443 |
NewerOlder