I'm getting a weird regex validation failure for Kubernetes Api version - "extensions/v1beta1" while creating a deployment.
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]*)#x27;This is the Kubernetes yaml that I'm using:
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'The output for Kubectl version gives:
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"}If you use variable in your YAML, you can't use that YAML directly.
Its gives error, because of this $ symbol.
But you can build your deployment from this YAML, you have posted in your question, with the help of envsubst command.
This command will replace your ENV variable in YAML.
Lets say, you have already set this ENVs,
$ export ENVIRONMENT="ENV_DATA"
$ export DOCKER_REGISTRY_HOST="REGISTRY"
$ export BUILD_VERSION="TAG"
$ export SPARK_MASTER_MEMORY="5Gi"
$ export SPARK_MASTER_CPU="256Mi"Now, substitute ENV variable and create deployment.yaml using following command
$ cat deployment.yaml | envsubst | kubectl create -f -
deployment "sf-spark-master" created
Hope this will help
This error is caused by following variables used in deployment YAML
$BUILD_VERSION
$SPARK_MASTER_MEMORY
$SPARK_MASTER_CPUThis is not the problem of apiVersion of Deployment.
It failed to read the value of these variables.