Entering code / files directly into a container in Kubernet on Google Cloud Engine

How can I enter code / files directly into a container in Kubernetes in Google Cloud Engine, similar to how you can mount host files / directories using Docker, for example.

docker run -d --name nginx -p 443:443 -v "/nginx.ssl.conf:/etc/nginx/conf.d/default.conf"

thanks

+6
source share
3 answers

I'm not sure you can do it for sure. Kubernetes does things differently than docker, and is actually not ideal for interacting with the "host" with which you are probably used to docker.

. -, , , , , , , commands args pod kubectl exec echo'ing . -, , , . GCE EBS, , ( ) . -, , .

kubectl exec , /. / , , , . , , , , CI (, drone) .

, .

+6

ConfigMaps:

mariadb POD mariadb:

ConfigMap

apiVersion: v1
data:
  charset.cnf: |
    [client]
    # Default is Latin1, if you need UTF-8 set this (also in server section)
    default-character-set = utf8 

    [mysqld]
    #
    # * Character sets
    #
    # Default is Latin1, if you need UTF-8 set all this (also in client section)
    #
    character-set-server  = utf8 
    collation-server      = utf8_unicode_ci 

kind: ConfigMap
metadata:
  name: mariadb-configmap

MariaDB

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mariadb
  labels:
    app: mariadb  
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: mariadb
        version: 10.1.16
    spec:
      containers:
      - name: mariadb
        image: mariadb:10.1.16
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mariadb
              key: rootpassword
        volumeMounts:
        - name: mariadb-data
          mountPath: /var/lib/mysql
        - name: mariadb-config-file
          mountPath: /etc/mysql/conf.d   
      volumes:
      - name: mariadb-data
        hostPath: 
          path: /var/lib/data/mariadb
      - name: mariadb-config-file
        configMap:
          name: mariadb-configmap

subPath, 1.3, .

+11

Kubernetes allows you to mount volumes into your container. One of these types of volumes hostPath( link ), which allows you to mount the directory from the host to the module.

0
source

Source: https://habr.com/ru/post/1618372/


All Articles