Discover Docker, K8s and Xen Server with Maksym Prokopov

Insights, discussion, bugs and how-tos about Docker, CoreOS, orchestration and other interesting things.

Sometimes you need to implement ordered loading for the pods. Say, launch rabbit mq container first, than your app container. This could be done using initContainer concept.

Put this into values.yaml of your helm chart definition

rabbit:
  host: rabbit

and this to the app deployment.yaml definition

initContainers:
        - name: check-rabbit-ready
          image: public.ecr.aws/runecast/busybox:1.33.1
          command: ['sh', '-c', 'until nc -vz {{ .Values.rabbit.host }} 5672; do echo "Waiting for rabbit service"; sleep 2; done;']

For Amazon EKS:

kubectl describe nodes -l topology.kubernetes.io/zone=eu-central-1a
find . -name *.log | xargs truncate -s0

Use the following code snippet:

telegram:
  enabled: False

Env:
  - TELEGRAM_NOTIFICATION={{ telegram.enabled | ternary('true', None)}}

In this way False value evaluates to None and as outcome you'll get empty TELEGRAM_NOTIFICATION variable

docker ps -f status=exited -q | xargs docker rm
Aug 27, 2021, 13:00

Execute eksctl from terraform

cluster_name and profile are terraform variables

resource "null_resource" "oidc_provider" {
  triggers = {
    cluster_name = var.cluster_name
  }

  provisioner "local-exec" {
    command = <<EOF
AWS_PROFILE=${var.profile} eksctl utils associate-iam-oidc-provider --cluster ${var.cluster_name} --approve
EOF
  }
}

Check result with command

aws iam list-open-id-connect-providers | jq ".OpenIDConnectProviderList[].Arn"
Jul 29, 2021, 16:54

aws list ec2 instances by tag

simple ec2 instances list using jq

aws ec2 describe-instances | jq -r '.Reservations | .[].Instances | .[].Tags | .[] | select(.Key == "Name") | .Value'
Jan 23, 2021, 12:59

enable gitea to use ssh port 22

  1. Move original ssh service to other port, like 2022
  2. set gitea config to use port 22
    app.ini
[server]
DISABLE_SSH      = false
SSH_PORT         = 22
SSH_LISTEN_HOST  = 0.0.0.0
SSH_LISTEN_PORT  = 22
START_SSH_SERVER = true
  1. execute
sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/gitea to enable usage of the port 22

let's say you have true in the hundreds of files and you need to copy only those which contain this string, it is quite easy to do with Linux find utility

grep -l -ri -m1 "Active>true" */*.xml | xargs -I {} cp {} target_folder
find . -type f -name coverage.cov -exec bash -c 'cp {} $(pwd)/.coverage/cov/${RANDOM}.cov' \;
Ctrl + ↓ Earlier