kubectl create

command( command)

Syntax

kubectl create <resource> <name> [flags]

Parameters

ParametersDescriptionExamplesLevel
--image kubectl create deployment nginx --image=nginx:1.25 Common
--replicas kubectl create deployment web --image=nginx --replicas=3 Common
--dry-run=client YAML kubectl create deployment web --image=nginx --dry-run=client -o yaml Common
--from-literal ConfigMap/Secret kubectl create configmap app-config --from-literal=key=value Common
--from-file ConfigMap/Secret kubectl create configmap app-config --from-file=config.yaml Common

Examples

Deployment

kubectl create deployment nginx --image=nginx:1.25 --replicas=3
3 Nginx

YAML

kubectl create deployment web --image=nginx --dry-run=client -o yaml > deployment.yaml
create YAML apply

ConfigMap

kubectl create configmap db-config --from-literal=DB_HOST=mysql --from-literal=DB_PORT=3306

Secret

kubectl create secret generic db-secret --from-literal=password=mypassword
Base64

kubectl create namespace staging
New

Common Errors

already exists, kubectl apply New
invalid image name,

Tips

Related Commands