/ ์ข ๋ฅ์ ๋ฒ๊ทธ
๋ฒ๊ทธ ๋ผ๊ณ ์๊ฐํฉ๋๋ค
๋ฌด์จ ์ผ์ด ์ผ์ด ๋ฌ์ต๋๊น?
kubectl์ ์ ํจํ์ง ์์ ๋ฐ์ดํฐ๊ฐ ํฌํจ ๋ yaml ํ์ผ์ ์ฑ๊ณต์ ์ผ๋ก ๊ฒ์ฆํฉ๋๋ค (yaml ํ์ผ ๋ด์ฉ์ ์๋ ์ฐธ์กฐ).
$ kubectl --context=minikube create --dry-run --validate -f invalid.yml
deployment "test" created (dry run)
๊ทธ๋ฌ๋ ์ ํจ์ฑ ๊ฒ์ฌ์์ด ๋ช ๋ น์ ์คํํ๋ฉด ์คํจํฉ๋๋ค.
$ kubectl --context=minikube apply -f invalid.yml
The Deployment "test" is invalid:
* metadata.labels: Invalid value: "ยฃ\"+=_+!ยนยฒยณโฌ}{{@\"}{@~@:>?|\\|ยฌ`}": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
* spec.replicas: Invalid value: -100: must be greater than or equal to 0
* spec.selector.matchLabels: Invalid value: "ยฃ\"+=_+!ยนยฒยณโฌ}{{@\"}{@~@:>?|\\|ยฌ`}": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
* spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"ยฃ\"+=_+!ยนยฒยณโฌ}{{@\"}{@~@:>?|\\|ยฌ`}"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: invalid label selector.
์์ ํ ์ผ :
kubectl create --dry-run --validate
์์ yaml ํ์ผ์ ์ค๋ฅ๊ฐ ์์์๋ณด๊ณ ํด์ผํฉ๋๋ค.
์ฌํ ๋ฐฉ๋ฒ (๊ฐ๋ฅํ ํ ์ต์ํ์ผ๋ก ์ ํํ๊ฒ) :
์๋ yaml์ yaml ํ์ผ์ ์ ์ฅํ๊ณ ๋ค์์ ์ฌ์ฉํ์ฌ ํ ๋ฒ ์ ์ฉํ์ญ์์ค.
kubectl create --dry-run --validate -f file.yaml
๊ทธ๋ฆฌ๊ณ ์ง์ง๋ก
kubectl create -f file.yaml
Minikube๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test
labels:
app: ยฃ"+=_+!ยนยฒยณโฌ}{{@"}{@~@:>?|\|ยฌ`}
namespace: default
spec:
replicas: -100
revisionHistoryLimit: 2
template:
metadata:
labels:
app: ยฃ"+=_+!ยนยฒยณโฌ}{{@"}{@~@:>?|\|ยฌ`}
spec:
containers:
- image: ยฃ"+=_+!ยนยฒยณโฌ}{{@"}{@~@:>?|\|ยฌ`}
name: ยฃ"+=_+!ยนยฒยณโฌ}{{@"}{@~@:>?|\|ยฌ`}
envFrom:
- secretRef:
name: ยฃ"+=_+!ยนยฒยณโฌ}{{@"}{@~@:>?|\|ยฌ`}
์ฐ๋ฆฌ๊ฐ ์์์ผ ํ ๋ค๋ฅธ ๊ฒ์ด ์์ต๋๊น? :
ํ๊ฒฝ :
kubectl version
) :NAME="Linux Mint"
VERSION="18.3 (Sylvia)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 18.3"
VERSION_ID="18.3"
VERSION_CODENAME=sylvia
UBUNTU_CODENAME=xenial
์ปค๋ (์ : uname -a
) :
Linux nb 4.13.0-43-generic # 48 ~ 16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018 x86_64 x86_64 x86_64 GNU / Linux
๋๊ตฌ ์ค์น :
/ sig cli
ํด๋ผ์ด์ธํธ ์ธก ์ ํจ์ฑ ๊ฒ์ฌ๋ ์์ ํ์ง ์์ต๋๋ค. ์ฃผ๋ก yaml ํ์ผ์ ํ๋ ์ด๋ฆ๊ณผ ์ ํ์ด ์ ํจํ์ง ํ์ธํฉ๋๋ค. ์ ์ฒด ์ ํจ์ฑ ๊ฒ์ฌ๋ ํญ์ ์๋ฒ์์ ์ํํ๋ฉฐ ํญ์ ํด๋ผ์ด์ธํธ ์ธก ์ ํจ์ฑ ๊ฒ์ฌ์ ๋ํ ์ถ๊ฐ ์ ํ / ์ ์ฝ์ ๋ถ๊ณผ ํ ์ ์์ต๋๋ค.
/๋ซ๊ธฐ
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
ํด๋ผ์ด์ธํธ ์ธก ์ ํจ์ฑ ๊ฒ์ฌ๋ ์์ ํ์ง ์์ต๋๋ค. ์ฃผ๋ก yaml ํ์ผ์ ํ๋ ์ด๋ฆ๊ณผ ์ ํ์ด ์ ํจํ์ง ํ์ธํฉ๋๋ค. ์ ์ฒด ์ ํจ์ฑ ๊ฒ์ฌ๋ ํญ์ ์๋ฒ์์ ์ํํ๋ฉฐ ํญ์ ํด๋ผ์ด์ธํธ ์ธก ์ ํจ์ฑ ๊ฒ์ฌ์ ๋ํ ์ถ๊ฐ ์ ํ / ์ ์ฝ์ ๋ถ๊ณผ ํ ์ ์์ต๋๋ค.