Using secrets

Secrets can be accessed from your clusters by two mechanisms: through a mounted volume or through set environment variables. Exposing secrets to your cluster workloads occurs at deployment time by declaring either volumes or environment variables that reference your secrets.

This is an updated version of our basic deployment YAML file that now includes a configuration definition for a mounted volume referencing our creds secret:

---apiVersion: "extensions/v1beta1"kind: "Deployment"metadata:  name: "nginx-1"  namespace: "default"  labels:    app: "nginx-1"spec:  replicas: 3  selector:    matchLabels:      app: "nginx-1"  template:    metadata:      labels:        app: "nginx-1"    spec:      containers:      - name: "nginx"        image: "nginx:latest"        env: - name: creds-username ...

Get Building Google Cloud Platform Solutions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.