Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

name of envFrom.configMapRef need validate when create pod #42037

Closed
mdshuai opened this issue Feb 24, 2017 · 3 comments · Fixed by #42083
Closed

name of envFrom.configMapRef need validate when create pod #42037

mdshuai opened this issue Feb 24, 2017 · 3 comments · Fixed by #42083
Assignees

Comments

@mdshuai
Copy link

mdshuai commented Feb 24, 2017

Is this a BUG REPORT or FEATURE REQUEST? (choose one):
BUG

Kubernetes version (use kubectl version):
v1.7.0-alpha.0.161+56841e84f66746-dirty

What happened:
When create pod with invalid envFrom.configMapRef.name, should valid it not until start the container

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

[root@dhcp-140-98 dma]# cat pod1.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: config-env-example
spec:
  containers:
  - name: hello-pod
    image: docker.io/ocpqe/hello-pod:latest
    ports:
    - containerPort: 8080
      protocol: TCP
    env:
    - name: duplicate_key
      value: FROM_ENV
    - name: expansion
      value: $(REPLACE_ME)
    envFrom:
    - configMapRef:
        name: $%^&*#
[root@dhcp-140-98 dma]# kubectl create -f pod1.yaml 
pod "config-env-example" created
[root@dhcp-140-98 dma]# kubectl describe pod config-env-example
Name:		config-env-example
Namespace:	default
Node:		127.0.0.1/127.0.0.1
Start Time:	Fri, 24 Feb 2017 15:13:09 +0800
Labels:		<none>
Status:		Pending
IP:		
Controllers:	<none>
Containers:
  hello-pod:
    Container ID:	
    Image:		docker.io/ocpqe/hello-pod:latest
    Image ID:		
    Port:		8080/TCP
    State:		Waiting
      Reason:		ContainerCreating
    Ready:		False
    Restart Count:	0
    Volume Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-sc3zr (ro)
    Environment Variables from:
      $%^&*#	ConfigMap	Optional: false
    Environment Variables:
      duplicate_key:	FROM_ENV
      expansion:	$(REPLACE_ME)
Conditions:
  Type		Status
  Initialized 	True 
  Ready 	False 
  PodScheduled 	True 
Volumes:
  default-token-sc3zr:
    Type:	Secret (a volume populated by a Secret)
    SecretName:	default-token-sc3zr
    Optional:	false
QoS Class:	BestEffort
Node-Selectors:	<none>
Tolerations:	<none>
Events:
  FirstSeen	LastSeen	Count	From			SubObjectPath	Type		Reason		Message
  ---------	--------	-----	----			-------------	--------	------		-------
  11s		11s		1	default-scheduler			Normal		Scheduled	Successfully assigned config-env-example to 127.0.0.1
  11s		11s		1	kubelet, 127.0.0.1			Normal		SandboxReceived	Pod sandbox received, it will be created.
  11s		11s		1	kubelet, 127.0.0.1			Warning		FailedSync	Error syncing pod, skipping: failed to "CreatePodSandbox" for "config-env-example_default(b21e80e0-fa60-11e6-b0ae-68f7281d8004)" with CreatePodSandboxError: "GeneratePodSandboxConfig for pod \"config-env-example_default(b21e80e0-fa60-11e6-b0ae-68f7281d8004)\" failed: invalid resource name \"$%^&*#\": [may not contain '%']"

Anything else we need to know:

@mdshuai
Copy link
Author

mdshuai commented Feb 24, 2017

@fraenkel @pmorie help check, thanks

@fraenkel
Copy link
Contributor

Good catch. It isn't validating that it has a valid name just that it exists. Same problem exists with a SecretRef.

@fraenkel
Copy link
Contributor

Although this is consistent with the validation for ConfigMapKeyRef and SecretKeyRef.

k8s-github-robot pushed a commit that referenced this issue Apr 3, 2017
Automatic merge from submit-queue (batch tested with PRs 42038, 42083)

Validate ConfigMapRef and SecretRef name

fixes #42037

**Release note**:
```release-note
When creating a container using envFrom,
1. validate the name of the ConfigMap in a ConfigMapRef
2. validate the name of the Secret in a SecretRef
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants