我为Kubernetes Api版本获得了一个奇怪的正则表达式验证失败 - " extensions / v1beta1"在创建部署时。
kubectl --kubeconfig=/var/go/.kube/mcc-pp-config --context=sam-mcc2-pp --namespace=sam-mcc2-pp apply -f k8s-config-sam-mcc2-pp/sf-spark-worker-deployment.yaml --record
Error from server (BadRequest): error when creating "k8s-config-sam-mcc2-pp/sf-spark-worker-deployment.yaml": Deployment in version "v1beta1" cannot be handled as a Deployment: quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
这是我正在使用的Kubernetes yaml:
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: sf-spark-master
spec:
replicas: 1
progressDeadlineSeconds: 30
selector:
matchLabels:
app: sf-spark-master
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: sf-spark-master
deployment: '$BUILD_VERSION'
spec:
containers:
- name: sf-spark-master
env:
- name: ENVIRONMENT
value: '$ENVIRONMENT'
- name: INIT_DAEMON_STEP
value: 'setup_spark'
image: '$DOCKER_REGISTRY_HOST/salesiq-article-cache-stub:build-$BUILD_VERSION'
ports:
- containerPort: 8080
protocol: TCP
- containerPort: 7077
protocol: TCP
- containerPort: 6066
protocol: TCP
resources:
limits:
memory: '$SPARK_MASTER_MEMORY'
cpu: '$SPARK_MASTER_CPU'
Kubectl版本的输出给出:
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:44:27Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.7", GitCommit:"8eb75a5810cba92ccad845ca360cf924f2385881", GitTreeState:"clean", BuildDate:"2017-04-27T09:42:05Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
答案 0 :(得分:0)
此错误是由部署YAML中使用的以下变量引起的
$BUILD_VERSION
$SPARK_MASTER_MEMORY
$SPARK_MASTER_CPU
这不是部署的apiVersion
问题。
无法读取这些变量的值。
答案 1 :(得分:0)
如果您在YAML中使用变量,则无法直接使用该YAML。
由于此$
符号,它会出错。
但您可以使用envsubst
命令在此问题中构建您的部署,您已在$ export ENVIRONMENT="ENV_DATA"
$ export DOCKER_REGISTRY_HOST="REGISTRY"
$ export BUILD_VERSION="TAG"
$ export SPARK_MASTER_MEMORY="5Gi"
$ export SPARK_MASTER_CPU="256Mi"
命令的帮助下发布了该部署。
此命令将替换YAML中的ENV变量。
让我们说,你已经设置了这个ENVs,
deployment.yaml
现在,使用以下命令替换ENV变量并创建$ cat deployment.yaml | envsubst | kubectl create -f -
deployment "sf-spark-master" created
def store_dir
"uploads/logo/#{model.id}"
end
希望这会有所帮助