Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
    • Helm Chart
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log & Monitor
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Kubernestes] Inserting command inside docker-compose or the manifest of a deployment

Posted on April 2, 2022 By nim No Comments on [Kubernestes] Inserting command inside docker-compose or the manifest of a deployment

Chuyện là thế này. Chắc anh em hẳn ai cũng biết là khi run 1 image docker lên 1 container thì đâu hặn container đó chạy mãi mãi.
Container có thể bị crash hoặc chạy xong process thì nó tắt.

Có 1 cách bình hay sử dụng như trước là mình build lại Dockerfile và nhét vào entrypoint 1 script hay 1 command để nó keep hay tạo ra 1 process chạy hoài không nghỉ.
==> thế là container sẽ không bị shutdown.

Giờ mình thấy 1 các nữa là bạn nhét command vào trong file docker compose hoặc manifest của deployment.
để sau khi run pod thành công thì nó run command này.

Với docker-compose.yaml

version: '2'
services:
  kafkacat:
    image: edenhill/kafkacat:1.6.0
    container_name: kafkacat
    entrypoint: 
      - /bin/sh 
      - -c 
      - |
        apk add jq; 
        while [ 1 -eq 1 ];do sleep 60;done

với manifest của kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    workload.user.cattle.io/workloadselector: deployment-kafka-kafkacat
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      workload.user.cattle.io/workloadselector: deployment-kafka-kafkacat
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        workload.user.cattle.io/workloadselector: deployment-kafka-kafkacat
    spec:
      containers:
      - args:
        - -c
        - apk add jq; while [ 1 -eq 1 ];do sleep 60;done
        command:
        - /bin/sh
        image: edenhill/kafkacat:1.6.0
        imagePullPolicy: Always
        name: kafkacat

Reference Links:
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#use-environment-variables-to-define-arguments

Kubernetes

Post navigation

Previous Post: [Kafka-Connect] Overwrite value of Key on Mongo Source Connector – Mongodb
Next Post: [Kubernetes] Changing DNS or Hosts of the POD on Kubernetes

More Related Articles

[Terraform/GCP/K8s] How can we build/install the Kubernetes clusters (GKE) on Google Cloud. GCP - Google Cloud
[Kubernetes] Having unbound immediate PersistentVolumeClaims Kubernetes
[Kubernetes] Changing DNS or Hosts of the POD on Kubernetes Kubernetes
[Cosign/Kyverno]Signing And Verifying Container Images With Sigstore Cosign And Kyverno Kubernetes
[Keda] Auto-scaling is so easy when you use Keda AWS - Amazon Web Service
[Kubernetes] How to delete Persistent Volume is Terminating and very stubborn Kubernetes

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Prometheus/Grafana] Install Prometheus and Grafana on ubuntu. March 27, 2023
  • [Kong Gateway] WebSocket connection failed March 26, 2023
  • [Nextcloud] Can’t download files to have a size bigger than 2Gi on NextCloud – RaspBerry March 24, 2023
  • [Datadog] Using DataDog to monitor all services on kubernetes March 19, 2023
  • [Metrics Server] Failed to make webhook authorizer request: the server could not find the requested resource March 17, 2023

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • Golang
    • Jquery & JavaScript
    • Laravel
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
    • Longhorn – Storage
    • MetalLB
    • Vault
    • VictoriaMetrics
  • Log & Monitor
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2023 NimTechnology.