Passing Docker container's run parameters in Kubernetes -
i have 2 containers (gitlab , postgresql) running on rancheros v1.0.3. make them part of kubernetes cluster.
[rancher@rancher-agent-1 ~]$ cat postgresql.sh docker run --name gitlab-postgresql -d \ --env 'postgres_db=gitlabhq_production' \ --env 'postgres_user=gitlab' --env 'postgres_password=password' \ --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \ postgres:9.6-2 [rancher@rancher-agent-1 ~]$ cat gitlab.sh docker run --name gitlab -d \ --link gitlab-postgresql:postgresql \ --publish 443:443 --publish 80:80 \ --env 'gitlab_port=80' --env 'gitlab_ssh_port=10022' \ --env 'gitlab_secrets_db_key_base=64-char-key-a' \ --env 'gitlab_secrets_secret_key_base=64-char-key-b' \ --env 'gitlab_secrets_otp_key_base=64-char-key-c' \ --volume /srv/docker/gitlab/gitlab:/home/git/data \ sameersbn/gitlab:9.4.5
queries:
1) have idea how use yaml files provision pods, replication controller etc. not sure how pass above docker run
parameters kubernetes can apply same image(s) correctly.
2) i'm not sure whether --link
argument (used in gitlab.sh
above) need passed in kubernetes. although deploying both containers on single host creating cluster of each (postgresql , gitlab) later, wanted confirm whether inter-host communication automatically taken care of kubernetes. if not, options can explored?
you should first try represent run statements docker-compose.yml
file. quite easy , turn below
version: '3' services: postgresql: image: postgres:9.6-2 environment: - "postgres_db=gitlabhq_production" - "postgres_user=gitlab" - "postgres_password=password" volumes: - /srv/docker/gitlab/postgresql:/var/lib/postgresql gitlab: image: sameersbn/gitlab:9.4.5 ports: - "443:443" - "80:80" environment: - "gitlab_port=80" - "gitlab_ssh_port=10022" - "gitlab_secrets_db_key_base=64-char-key-a" - "gitlab_secrets_secret_key_base=64-char-key-b" - "gitlab_secrets_otp_key_base=64-char-key-c" volumes: - /srv/docker/gitlab/gitlab:/home/git/data
now there amazing tool name kompose
kompose.io conversion part you. if convert above related files
$ kompose convert -f docker-compose.yml warn volume mount on host "/srv/docker/gitlab/gitlab" isn't supported - ignoring path on host warn volume mount on host "/srv/docker/gitlab/postgresql" isn't supported - ignoring path on host info kubernetes file "gitlab-service.yaml" created info kubernetes file "postgresql-service.yaml" created info kubernetes file "gitlab-deployment.yaml" created info kubernetes file "gitlab-claim0-persistentvolumeclaim.yaml" created info kubernetes file "postgresql-deployment.yaml" created info kubernetes file "postgresql-claim0-persistentvolumeclaim.yaml" created
now have fix volume mount part per kubernetes. completes 80% of work , need figure out rest 20%
here cat of generate files, can see kind of files generated
==> gitlab-claim0-persistentvolumeclaim.yaml <== apiversion: v1 kind: persistentvolumeclaim metadata: creationtimestamp: null labels: io.kompose.service: gitlab-claim0 name: gitlab-claim0 spec: accessmodes: - readwriteonce resources: requests: storage: 100mi status: {} ==> gitlab-deployment.yaml <== apiversion: extensions/v1beta1 kind: deployment metadata: creationtimestamp: null labels: io.kompose.service: gitlab name: gitlab spec: replicas: 1 strategy: type: recreate template: metadata: creationtimestamp: null labels: io.kompose.service: gitlab spec: containers: - env: - name: gitlab_port value: "80" - name: gitlab_secrets_db_key_base value: 64-char-key-a - name: gitlab_secrets_otp_key_base value: 64-char-key-c - name: gitlab_secrets_secret_key_base value: 64-char-key-b - name: gitlab_ssh_port value: "10022" image: sameersbn/gitlab:9.4.5 name: gitlab ports: - containerport: 443 - containerport: 80 resources: {} volumemounts: - mountpath: /home/git/data name: gitlab-claim0 restartpolicy: volumes: - name: gitlab-claim0 persistentvolumeclaim: claimname: gitlab-claim0 status: {} ==> gitlab-service.yaml <== apiversion: v1 kind: service metadata: creationtimestamp: null labels: io.kompose.service: gitlab name: gitlab spec: ports: - name: "443" port: 443 targetport: 443 - name: "80" port: 80 targetport: 80 selector: io.kompose.service: gitlab status: loadbalancer: {} ==> postgresql-claim0-persistentvolumeclaim.yaml <== apiversion: v1 kind: persistentvolumeclaim metadata: creationtimestamp: null labels: io.kompose.service: postgresql-claim0 name: postgresql-claim0 spec: accessmodes: - readwriteonce resources: requests: storage: 100mi status: {} ==> postgresql-deployment.yaml <== apiversion: extensions/v1beta1 kind: deployment metadata: creationtimestamp: null labels: io.kompose.service: postgresql name: postgresql spec: replicas: 1 strategy: type: recreate template: metadata: creationtimestamp: null labels: io.kompose.service: postgresql spec: containers: - env: - name: postgres_db value: gitlabhq_production - name: postgres_password value: password - name: postgres_user value: gitlab image: postgres:9.6-2 name: postgresql resources: {} volumemounts: - mountpath: /var/lib/postgresql name: postgresql-claim0 restartpolicy: volumes: - name: postgresql-claim0 persistentvolumeclaim: claimname: postgresql-claim0 status: {} ==> postgresql-service.yaml <== apiversion: v1 kind: service metadata: creationtimestamp: null labels: io.kompose.service: postgresql name: postgresql spec: clusterip: none ports: - name: headless port: 55555 targetport: 0 selector: io.kompose.service: postgresql status: loadbalancer: {}
wiki
Comments
Post a Comment