Rod Stewart:
Is anyone familiar with a way to specify the pod name (in the metadata block) via kubectl?
Andrey Dudin:
metadata:
name: %PODNAME%
what a problem?
Rod Stewart:
Understood, but how do you specify that via kubectl on the command line?
Andrey Dudin:
kubectl run %PODNAME% --image nginx
Andrey Dudin:
Usage:
kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json]
[--command] -- [COMMAND] [args...] [options]
Rod Stewart:
Sorry, let me rephrase the question. Is there a way via kubectl to specify a different name for the Pod and Container?
Rod Stewart:
Ah, i figured it out, thanks!
kubectl run nginx --image=nginx --generator=run-pod/v1 --dry-run -o yaml --limits cpu=10m,memory=10Mi --requests cpu=2m,memory=2Mi --labels=env=dev --labels=billing=finance --overrides=‘{“metadata”: {“name”: “cname”}}’
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
billing: finance
name: cname
spec:
containers:
- image: nginx
name: nginx
resources:
limits:
cpu: 10m
memory: 10Mi
requests:
cpu: 2m
memory: 2Mi
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}