Home › Developer Tools › Kubernetes Secret Generator

Kubernetes Secret Generator

Enter key/value pairs or paste a .env file and get a ready-to-apply Kubernetes Secret: values are base64-encoded for you, names and keys are validated, and the matching kubectl command is shown. Switch to Decode to read the values of an existing Secret.

Last updated:

Data
Labels, annotations and options
Write values as

    Everything is encoded and decoded in this browser tab. Remember: base64 is an encoding, not encryption, so treat the output as a secret.

    Advertisement
    Advertisement

    How to use the Kubernetes Secret Generator

    1. Name the Secret and pick a namespace and type. Opaque is the general-purpose type for app settings.
    2. Add the data as key/value rows, paste a .env file, or add a file such as a certificate or JSON config as a key.
    3. Choose data or stringData: data stores base64 values; stringData lets you keep readable text that the API server encodes on write.
    4. Fix any red notes, then copy or download the YAML and run kubectl apply -f, or use the kubectl tab instead.
    5. Need to read a Secret? Open Decode Secret and paste the output of kubectl get secret NAME -o yaml.

    Kubernetes Secret types

    typeRequired keysTypical usekubectl shortcut
    OpaqueAnyApp passwords, API tokens, connection stringscreate secret generic
    kubernetes.io/dockerconfigjson.dockerconfigjsonPulling images from a private registry via imagePullSecretscreate secret docker-registry
    kubernetes.io/tlstls.crt, tls.keyHTTPS certificates for an Ingresscreate secret tls
    kubernetes.io/basic-authusername and/or passwordCredentials for basic authenticationcreate secret generic --type=…
    kubernetes.io/ssh-authssh-privatekeyGit over SSH, deploy keyscreate secret generic --type=…

    Using the Secret in a pod

    Load every key as an environment variable:

    containers:
      - name: app
        image: example/app:1.4.2
        envFrom:
          - secretRef:
              name: app-credentials

    Or mount it as files, one file per key, which suits certificates and config files and picks up updates without restarting the pod:

        volumeMounts:
          - name: creds
            mountPath: /etc/creds
            readOnly: true
    volumes:
      - name: creds
        secret:
          secretName: app-credentials

    Tips for handling Secrets safely

    • Do not commit Secret YAML to Git. base64 can be decoded by anyone. Use a tool such as Sealed Secrets, SOPS or an external secrets operator for GitOps workflows.
    • Watch for trailing newlines. echo "pass" | base64 encodes a newline too; use echo -n or printf. This tool encodes exactly what you type.
    • Limit access with RBAC: get and list on Secrets reveal their contents, and so does permission to create pods in the namespace.
    • Generate strong values with the Password Generator, and build the Deployment that uses the Secret with the Kubernetes YAML Generator.

    Frequently asked questions

    Why are Kubernetes Secret values base64-encoded?

    The data field of a Secret holds arbitrary bytes, such as certificates or keystores, and base64 lets those bytes travel safely inside YAML and JSON. It is only an encoding, not encryption: anyone who can read the Secret can decode it, so protect access with RBAC and consider encryption at rest for etcd.

    What is the difference between data and stringData?

    data expects base64-encoded values. stringData accepts plain text and is a write-only convenience: the API server encodes the values and merges them into data when the Secret is stored, and stringData wins if the same key is in both. When you read the Secret back, you always get data in base64.

    How do I create a Secret from a .env file?

    Paste the file into the Paste .env view of this tool and download the YAML, or run kubectl create secret generic NAME --from-env-file=.env. Each KEY=value line becomes one key in the Secret. You can then load all keys into a container as environment variables with envFrom and secretRef.

    How do I decode a Kubernetes Secret?

    Paste the output of kubectl get secret NAME -o yaml into the Decode Secret tab to see every value. On the command line you can decode one key with kubectl get secret NAME -o jsonpath='{.data.KEY}' piped into base64 --decode.

    What names and keys are allowed?

    The Secret name must be a DNS subdomain: lowercase letters, digits, hyphens and dots, up to 253 characters. Data keys may contain letters, digits, hyphens, underscores and dots. The namespace is a DNS label of at most 63 characters.

    How big can a Secret be?

    Each Secret is limited to 1 MiB of data, so large files belong in a volume or object storage instead. Many small Secrets are also better than one huge one, because each is sent to every node that runs a pod using it.

    What does immutable: true do?

    An immutable Secret cannot have its data changed after creation; you delete and recreate it instead. This protects against accidental edits and lets the kubelet stop watching it, which reduces load on the API server in large clusters.

    Are all the tools on FreeToolCabin tested for quality and accuracy?

    Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

    Related tools

    Kubernetes YAML GeneratorGenerate Deployment, Service, Ingress, ConfigMap, Secret and HPA manifests with safe defaults.Base64 Encoder DecoderEncode or decode Base64 text and files, and make data URIs.Docker Compose to KubernetesConvert docker-compose.yml into Kubernetes Deployment, Service, ConfigMap and PVC manifests.Kubernetes YAML ValidatorValidate Kubernetes manifests against the API schema of a chosen version, with error paths.QR Code GeneratorMake QR codes for links, Wi-Fi, email and more.Barcode GeneratorCreate Code 128, EAN-13, UPC-A, EAN-8, Code 39 and ITF-14 barcodes as PNG or SVG.UUID GeneratorGenerate UUID v4 and v7 / GUIDs in bulk and copy or download them.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Htaccess & Nginx Redirect GeneratorBuild 301 redirects for .htaccess, Nginx and Netlify or Cloudflare _redirects.Fake Data GeneratorGenerate mock data as JSON, CSV or SQL.Random String GeneratorGenerate secure random strings and tokens in bulk with any length and character set.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.MIME Type LookupFind the MIME type for any file extension, or the extensions for a MIME type, in 400+ entries.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.URL Slug GeneratorTurn titles into clean, SEO-friendly URL slugs: accents, stop words, separators and bulk lines.JSON Schema GeneratorTurn sample JSON into a draft 2020-12 JSON Schema with types, required fields and formats.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.License GeneratorCreate a LICENSE file for MIT, Apache, GPL, BSD, ISC, MPL or Unlicense with your name and year.ULID GeneratorGenerate sortable ULIDs and UUID v7 in bulk, monotonic option, and decode their timestamps.Htpasswd GeneratorCreate .htpasswd entries with bcrypt, APR1-MD5 or SHA-1 for Apache and Nginx basic auth.Placeholder Image GeneratorCreate placeholder images in any size, color and text as PNG, JPG, WebP, SVG or data URI.Ads.txt GeneratorCreate or validate ads.txt and app-ads.txt files: seller lines, cert IDs and variables.Docker Run to Compose ConverterConvert docker run commands to docker-compose.yml, or a compose file back to docker run.Dockerfile GeneratorGenerate a production Dockerfile and .dockerignore for Node, Python, Go or a static nginx site.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.JSON to Zod SchemaInfer a Zod (or Yup) schema from sample JSON with optional, nullable and z.infer types.Linux Commands Cheat SheetSearchable Linux and bash command reference with flags explained, examples and copy buttons.LLMs.txt GeneratorBuild an llms.txt file for AI crawlers: summary and link sections, import from your sitemap.Nano ID GeneratorGenerate secure Nano IDs with custom alphabet, length and count, plus a collision calculator.Nginx Config GeneratorBuild an nginx server block: static site, SPA, reverse proxy or PHP, with SSL, gzip and redirects.OpenAPI / Swagger ViewerView OpenAPI 2/3 JSON or YAML as interactive API docs with validation and an endpoint list.package.json GeneratorFill a form and get a valid, npm-ready package.json with scripts, dependencies and checks.PKCE Code Challenge GeneratorGenerate an OAuth 2.0 PKCE code_verifier and S256 code_challenge, build auth URLs, verify pairs.README GeneratorFill in a form and get a polished README.md with badges, install, usage and license, live preview.Regex GeneratorBuild regular expressions visually from blocks or presets (email, date, phone) and test them live.Commit Message GeneratorBuild Conventional Commit messages with type, scope, body, breaking change and issue refs.Database Schema DesignerDesign tables and relationships visually, then export SQL for MySQL, PostgreSQL or SQLite.Docker Compose GeneratorBuild a docker-compose.yml with a form: services, ports, volumes, env, healthchecks and presets.Prettier Config GeneratorToggle Prettier options, preview formatted code live and copy your .prettierrc file.Quartz Cron GeneratorBuild and explain Quartz and Spring cron expressions with seconds, ?, L, W and #, plus next fire times.README Badge GeneratorCreate Shields.io-style README badges for license, version, build and custom labels.Systemd Service File GeneratorCreate a systemd .service unit with ExecStart, user, restart policy, environment and hardening.tsconfig.json GeneratorBuild a tsconfig.json with target, module, strict checks and path aliases, each option explained.Access Log AnalyzerAnalyze Apache and Nginx access logs: top URLs, IPs, status codes, bots and traffic charts.Regex String GeneratorGenerate random test strings that match any regular expression, checked against the real regex.ASCII Table GeneratorTurn CSV or pasted cells into plain-text tables: MySQL, Markdown, Unicode box and reST styles.Dummy File GeneratorCreate test files of an exact size in KB, MB or GB with zeros, random bytes or text.FFmpeg Command GeneratorPick a task and options, get the exact ffmpeg command with every flag explained.Folder Tree GeneratorTurn a local folder or an indented list into an ASCII directory tree for your README.GitHub Actions Workflow GeneratorBuild a GitHub Actions CI workflow: triggers, matrix, caching, tests, Pages or Docker deploy.Markdown TOC GeneratorGenerate a linked table of contents from Markdown headings with GitHub-style anchors.OpenAPI EditorEdit OpenAPI/Swagger YAML or JSON side by side with live API docs, validation and download.OpenAPI ValidatorValidate OpenAPI 3.0/3.1 and Swagger 2.0 specs: schema errors, broken $refs, line numbers.Pivot Table MakerBuild pivot tables from CSV or Excel by drag and drop: sum, count, average, charts, export.SQL Query BuilderBuild SELECT queries visually: joins, filters, GROUP BY, ORDER BY and LIMIT, as clean SQL.Truth Table GeneratorType a logic expression and get its full truth table, minterms and canonical DNF/CNF.TypeScript PlaygroundWrite TypeScript with live type checking, see the compiled JavaScript and run it in your browser.Article Schema GeneratorCreate Article, BlogPosting or NewsArticle JSON-LD with headline, authors, dates and images.Event Schema GeneratorCreate Event JSON-LD with dates, venue or online location, tickets, organizer and performers.Google Search Query BuilderBuild advanced Google searches with site:, filetype:, intitle:, exact phrases and date operators.HowTo Schema GeneratorCreate HowTo JSON-LD with steps, tools, supplies, total time and cost, then copy it.Htaccess GeneratorBuild an Apache .htaccess file: HTTPS, www, gzip, caching, error pages, IP blocks, hotlinks.HTML Email Template BuilderDrag and drop blocks to build a responsive, table-based HTML email with inline styles.Organization Schema GeneratorCreate Organization JSON-LD with logo, URL, contact points, address and social profiles.PIN GeneratorGenerate random 4, 6 or 8-digit PINs that avoid sequences, repeats, dates and common PINs.Product Schema GeneratorBuild Product JSON-LD with price, availability, brand, GTIN, ratings and reviews.Question Keyword GeneratorFind the questions people ask about a topic, grouped by who, what, why, how, can and more.Recipe Schema GeneratorCreate Recipe JSON-LD with ingredients, steps, prep and cook times, nutrition and ratings.
    See all 85 Code Generators & Builders →