我正在嘗試使用 kubernetes 創建一個副本集。這一次,我沒有 yml 檔案,這就是我嘗試使用命令列創建副本集的原因。為什么kubectl create replicaset somename --image=nginx會引發錯誤,以及如何解決這個問題?
uj5u.com熱心網友回復:
您不能replicaset使用命令列創建。只能使用以下資源創建kubectl create:
kubectl create --help |awk '/Available Commands:/,/^$/'
Available Commands:
clusterrole Create a cluster role
clusterrolebinding Create a cluster role binding for a particular cluster role
configmap Create a config map from a local file, directory or literal value
cronjob Create a cron job with the specified name
deployment Create a deployment with the specified name
ingress Create an ingress with the specified name
job Create a job with the specified name
namespace Create a namespace with the specified name
poddisruptionbudget Create a pod disruption budget with the specified name
priorityclass Create a priority class with the specified name
quota Create a quota with the specified name
role Create a role with single rule
rolebinding Create a role binding for a particular role or cluster role
secret Create a secret using specified subcommand
service Create a service using a specified subcommand
serviceaccount Create a service account with the specified name
雖然,您可以使用以下方式創建副本集,但在下面的示例中,kubectl create -f使用 stdout( -) 提供:
echo "apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
" |kubectl create -f -
uj5u.com熱心網友回復:
您好,希望您享受您的 kubernetes 之旅!
事實上,你不能直接創建 RS,但如果你真的不想使用 manifest,你當然可以通過部署創建它:
? kubectl create deployment --image nginx:1.21 --port 80 test-rs
deployment.apps/test-rs created
這里是:
? kubectl get rs
NAME DESIRED CURRENT READY AGE
test-rs-5c99c9b8c 1 1 1 15s
猜猜
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/471155.html
