markdown Kubernetes的作弊表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Kubernetes的作弊表相关的知识,希望对你有一定的参考价值。

# Cheat Sheet of Kubernetes

- [ConfigMap](#file-config-map-md)
- [Environment Variable](#file-environment-variable-md)
- [Kubernetes Cheat Sheet (official)](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)
# ConfigMap

## Usage

Create an config yaml:

```yaml
# filename: db-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: db-config
  namespace: default
data:
  ENV_VAR: test
  ENV_VAR2: "123"
```

Ask kubectl to create from file:

```bash
$ kubectl create -f db-config.yaml
```

Check your configuration is applied:

```bash
$ kubectl get configmap
```

Edit you pod configuration or deployment:

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: demo-from-env
spec:
  containers:
  - name: envtest
    image: supergiantkir/k8s-liveliness
    ports:
    - containerPort: 8080
    envFrom:
    - configMapRef:
        name: db-config
```

Then apply your pod or deployment.

## Reference

- [Configuring Kubernetes Apps Using ConfigMaps](https://supergiant.io/blog/configuring-kubernetes-apps-using-configmaps)
# Environment Variable

## Usage

```yaml
# pods/inject/envars.yaml

apiVersion: v1
kind: Pod
metadata:
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  containers:
  - name: envar-demo-container
    image: gcr.io/google-samples/node-hello:1.0
    env:
    - name: DEMO_GREETING
      value: "Hello from the environment"
    - name: DEMO_FAREWELL
      value: "Such a sweet sorrow"

```

## Reference 

- [Define Environment Variables for a Container](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/)

以上是关于markdown Kubernetes的作弊表的主要内容,如果未能解决你的问题,请参考以下文章

markdown Pipenv作弊表用于常见命令

markdown Git作弊表

markdown MongoDb作弊表

markdown MongoDb作弊表

markdown Mocha,Chai和Sinon的终极单元测试作弊表

markdown Mocha,Chai和Sinon的终极单元测试作弊表