Docker Kubernates - ashish-ghub/docs GitHub Wiki

Docker

few useful command for docker :

1) install and run redis standalone in docker desktop

    **docker run --name my-redis -p 6379:6379 -d redis**

2) Because of security and keeping docker image small in size we keep very light version of operating system base image so to debug we need some of the linux command on issue container how to do that :

  • 2a) find binary at bastion host $> which netstat $> /usr/bin/netstat

  • 2b) copy binaries from bastion host to issue container

~/environment $ kubectl cp /usr/bin/netstat :/opt/com/script -c

  • 2c) run command

/opt/com/script> ./netstat -nlp | grep :5556

3. kafka-docker-setup https://www.baeldung.com/ops/kafka-docker-setup

4. UBI images:

5. Helm:


1. https://spring.io/guides/topicals/spring-boot-docker/

Kubernates:

1. Kubernetes best practices

https://cloud.google.com/blog/products/containers-kubernetes/your-guide-kubernetes-best-practices

2. Commands :

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

3. Kubernetes articles

https://dzone.com/articles/five-myths-of-kubernetes

4. Docker Compose File to Kubernetes Resources

Trouble shooting :

1. Exit code 137 - Pods terminated

 137 exit code mostly because of memory but found that this is not always true as below 2 cases :

a) Because of memory as OOMKilled

 Last State:   Terminated
 Reason:       OOMKilled
 Exit Code:    137

https://komodor.com/learn/how-to-fix-oomkilled-exit-code-137/

b) because of disk space : ephemeral-storage

 Last State:   Terminated
 Reason:       Error
 Exit Code:    137

https://discuss.kubernetes.io/t/exit-code-137-pods-terminated/9291

Found that there was no issue with memory , gc logs was fine but pod got restarted. from application logs found that debug logs were enabled. Seems like this might cause to eat up the disk spaces as debug logs are very frequent result to increase log file size.

  • To enable access logs on spring boot based running container without code change and rebuild of image

kubectl set env deployment/platform-oauth2-server -c platform-oauth2 SERVER_TOMCAT_ACCESSLOG_ENABLED=true

  • to enable headers to log in access log file

kubectl set env deployment/platform-oauth2-server -c platform-oauth2 SERVER_TOMCAT_ACCESSLOG_PATTERN='%{X-Forwarded-Proto}i %{X-Forwarded-Prefix}i %{X-Forwarded-Ssl}i %{X-Forwarded-Host}i %{X-Forwarded-Port}i %h %l %u %t "%r" %s %b'