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

configmap file as executable script #71356

Closed
FritschAuctores opened this issue Nov 22, 2018 · 5 comments
Closed

configmap file as executable script #71356

FritschAuctores opened this issue Nov 22, 2018 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one.

Comments

@FritschAuctores
Copy link

FritschAuctores commented Nov 22, 2018

What would you like to be added:

A configmap file as executable script into a pod

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-script
data:
  test.sh: |
   #!/bin/bash
   echo "Hello World"

Pod:

...
       volumeMounts:
        - name: test-script
          mountPath: /script/test.sh
          subPath: test.sh
      - name: test-script
        configMap:
          name: test-script
...

Inside the Pod:

From
-rw-r--r-- 1 root root 1.3K Nov 22 15:32 test.sh
To
-rwxr-xr-x 1 root root 1.3K Nov 22 15:41 test.sh

Why is this needed:

It is easier to create a flexible Pod

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 22, 2018
@k8s-ci-robot
Copy link
Contributor

@FritschAuctores: There are no sig labels on this issue. Please add a sig label by either:

  1. mentioning a sig: @kubernetes/sig-<group-name>-<group-suffix>
    e.g., @kubernetes/sig-contributor-experience-<group-suffix> to notify the contributor experience sig, OR

  2. specifying the label manually: /sig <group-name>
    e.g., /sig scalability to apply the sig/scalability label

Note: Method 1 will trigger an email to the group. See the group list.
The <group-suffix> in method 1 has to be replaced with one of these: bugs, feature-requests, pr-reviews, test-failures, proposals.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Nov 22, 2018
@FritschAuctores
Copy link
Author

FritschAuctores commented Nov 22, 2018

/sig-feature-requests

@tossmilestone
Copy link
Member

@FritschAuctores It's already supported in k8s to specify the file permissions of mounted configmap files. You can reference the usage in secret https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod.

@FritschAuctores
Copy link
Author

FritschAuctores commented Nov 23, 2018

Thank you, this works:

Pod:

...
       volumeMounts:
        - name: test-script
          mountPath: /script/test.sh
          subPath: test.sh
      - name: test-script
        configMap:
          name: test-script
          defaultMode: 0777
...

/close

@ToniRib
Copy link

ToniRib commented May 8, 2023

For anyone that lands here and is wondering how you set this is you're using JSON overrides, you need the decimal equivalent of the defaultMode octal. This works:

    "volumes": [
      {
        "name": "database-administration-config",
        "configMap": {
          "name": "database-administration-config",
          "defaultMode": 493
        }
      }
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

4 participants