Accessing Kubernetes Secret from Airflow KubernetesPodOperator Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!What's the difference between Apache's Mesos and Google's KubernetesKubernetes Pod fails with CrashLoopBackOffHow to protect k8s secrets using rbac?Kubernetes - Jenkins integrationHow to validate airflow DAG with customer operator?How to force jinja templating on airflow variable?Jenkins Kubernetes plugin failing to provision jnlp-slave podsPrivate images with Airflow KubernetesPodOperatorRetrieve Kubernetes' Secret from Google Composer (Airflow)Airflow no module named 'kubernetes'
'Var' does not name a type!
Could moose/elk survive in the Amazon forest?
What is /etc/mtab in Linux?
Is Bran literally the world's memory?
Protagonist's race is hidden - should I reveal it?
How to count in linear time worst-case?
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
Are all CP/M-80 implementations binary compatible?
What's parked in Mil Moscow helicopter plant?
How long after the last departure shall the airport stay open for an emergency return?
How to keep bees out of canned beverages?
Is a 5 watt UHF/VHF handheld considered QRP?
How can I make a line end at the edge of an irregular shape?
Mistake in years of experience in resume?
Implementing 3DES algorithm in Java: is my code secure?
What is the ongoing value of the Kanban board to the developers as opposed to management
Does the set of sets which are elements of every set exist?
Suing a Police Officer Instead of the Police Department
Is Electric Central Heating worth it if using Solar Panels?
Married in secret, can marital status in passport be changed at a later date?
Split coins into combinations of different denominations
How do I check if a string is entirely made of the same substring?
What is the best argument for maximum parsimony method in phylogenetic tree construction?
Co-worker works way more than he should
Accessing Kubernetes Secret from Airflow KubernetesPodOperator
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!What's the difference between Apache's Mesos and Google's KubernetesKubernetes Pod fails with CrashLoopBackOffHow to protect k8s secrets using rbac?Kubernetes - Jenkins integrationHow to validate airflow DAG with customer operator?How to force jinja templating on airflow variable?Jenkins Kubernetes plugin failing to provision jnlp-slave podsPrivate images with Airflow KubernetesPodOperatorRetrieve Kubernetes' Secret from Google Composer (Airflow)Airflow no module named 'kubernetes'
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm setting up an Airflow environment on Google Cloud Composer for testing. I've added some secrets to my namespace, and they show up fine:
$ kubectl describe secrets/eric-env-vars
Name: eric-env-vars
Namespace: eric-dev
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
VERSION_NUMBER: 6 bytes
I've referenced this secret in my DAG definition file (leaving out some code for brevity):
env_var_secret = Secret(
deploy_type='env',
deploy_target='VERSION_NUMBER',
secret='eric-env-vars',
key='VERSION_NUMBER',
)
dag = DAG('env_test', schedule_interval=None, start_date=start_date)
operator = KubernetesPodOperator(
name='k8s-env-var-test',
task_id='k8s-env-var-test',
dag=dag,
image='ubuntu:16.04',
cmds=['bash', '-cx'],
arguments=['env'],
config_file=os.environ['KUBECONFIG'],
namespace='eric-dev',
secrets=[env_var_secret],
)
But when I run this DAG, the VERSION_NUMBER env var isn't printed out. It doesn't look like it's being properly linked to the pod either (apologies for imprecise language, I am new to both Kubernetes and Airflow). This is from the Airflow task log of the pod creation response (also formatted for brevity/readability):
'env': [
'name': 'VERSION_NUMBER',
'value': None,
'value_from':
'config_map_key_ref': None,
'field_ref': None,
'resource_field_ref': None,
'secret_key_ref':
'key': 'VERSION_NUMBER',
'name': 'eric-env-vars',
'optional': None
]
I'm assuming that we're somehow calling the constructor for the Secret wrong, but I am not entirely sure. Guidance appreciated!
add a comment |
I'm setting up an Airflow environment on Google Cloud Composer for testing. I've added some secrets to my namespace, and they show up fine:
$ kubectl describe secrets/eric-env-vars
Name: eric-env-vars
Namespace: eric-dev
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
VERSION_NUMBER: 6 bytes
I've referenced this secret in my DAG definition file (leaving out some code for brevity):
env_var_secret = Secret(
deploy_type='env',
deploy_target='VERSION_NUMBER',
secret='eric-env-vars',
key='VERSION_NUMBER',
)
dag = DAG('env_test', schedule_interval=None, start_date=start_date)
operator = KubernetesPodOperator(
name='k8s-env-var-test',
task_id='k8s-env-var-test',
dag=dag,
image='ubuntu:16.04',
cmds=['bash', '-cx'],
arguments=['env'],
config_file=os.environ['KUBECONFIG'],
namespace='eric-dev',
secrets=[env_var_secret],
)
But when I run this DAG, the VERSION_NUMBER env var isn't printed out. It doesn't look like it's being properly linked to the pod either (apologies for imprecise language, I am new to both Kubernetes and Airflow). This is from the Airflow task log of the pod creation response (also formatted for brevity/readability):
'env': [
'name': 'VERSION_NUMBER',
'value': None,
'value_from':
'config_map_key_ref': None,
'field_ref': None,
'resource_field_ref': None,
'secret_key_ref':
'key': 'VERSION_NUMBER',
'name': 'eric-env-vars',
'optional': None
]
I'm assuming that we're somehow calling the constructor for the Secret wrong, but I am not entirely sure. Guidance appreciated!
Does the value you expect inVERSION_NUMBERat least make its way intoBASE_IMAGE_VERSION?
– hexacyanide
Mar 22 at 16:04
@hexacyanide Yes, this is same variable, I just made an error in my editing of the logs and operators. Fixing that now.
– Eric Fulmer
Mar 22 at 16:05
add a comment |
I'm setting up an Airflow environment on Google Cloud Composer for testing. I've added some secrets to my namespace, and they show up fine:
$ kubectl describe secrets/eric-env-vars
Name: eric-env-vars
Namespace: eric-dev
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
VERSION_NUMBER: 6 bytes
I've referenced this secret in my DAG definition file (leaving out some code for brevity):
env_var_secret = Secret(
deploy_type='env',
deploy_target='VERSION_NUMBER',
secret='eric-env-vars',
key='VERSION_NUMBER',
)
dag = DAG('env_test', schedule_interval=None, start_date=start_date)
operator = KubernetesPodOperator(
name='k8s-env-var-test',
task_id='k8s-env-var-test',
dag=dag,
image='ubuntu:16.04',
cmds=['bash', '-cx'],
arguments=['env'],
config_file=os.environ['KUBECONFIG'],
namespace='eric-dev',
secrets=[env_var_secret],
)
But when I run this DAG, the VERSION_NUMBER env var isn't printed out. It doesn't look like it's being properly linked to the pod either (apologies for imprecise language, I am new to both Kubernetes and Airflow). This is from the Airflow task log of the pod creation response (also formatted for brevity/readability):
'env': [
'name': 'VERSION_NUMBER',
'value': None,
'value_from':
'config_map_key_ref': None,
'field_ref': None,
'resource_field_ref': None,
'secret_key_ref':
'key': 'VERSION_NUMBER',
'name': 'eric-env-vars',
'optional': None
]
I'm assuming that we're somehow calling the constructor for the Secret wrong, but I am not entirely sure. Guidance appreciated!
I'm setting up an Airflow environment on Google Cloud Composer for testing. I've added some secrets to my namespace, and they show up fine:
$ kubectl describe secrets/eric-env-vars
Name: eric-env-vars
Namespace: eric-dev
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
VERSION_NUMBER: 6 bytes
I've referenced this secret in my DAG definition file (leaving out some code for brevity):
env_var_secret = Secret(
deploy_type='env',
deploy_target='VERSION_NUMBER',
secret='eric-env-vars',
key='VERSION_NUMBER',
)
dag = DAG('env_test', schedule_interval=None, start_date=start_date)
operator = KubernetesPodOperator(
name='k8s-env-var-test',
task_id='k8s-env-var-test',
dag=dag,
image='ubuntu:16.04',
cmds=['bash', '-cx'],
arguments=['env'],
config_file=os.environ['KUBECONFIG'],
namespace='eric-dev',
secrets=[env_var_secret],
)
But when I run this DAG, the VERSION_NUMBER env var isn't printed out. It doesn't look like it's being properly linked to the pod either (apologies for imprecise language, I am new to both Kubernetes and Airflow). This is from the Airflow task log of the pod creation response (also formatted for brevity/readability):
'env': [
'name': 'VERSION_NUMBER',
'value': None,
'value_from':
'config_map_key_ref': None,
'field_ref': None,
'resource_field_ref': None,
'secret_key_ref':
'key': 'VERSION_NUMBER',
'name': 'eric-env-vars',
'optional': None
]
I'm assuming that we're somehow calling the constructor for the Secret wrong, but I am not entirely sure. Guidance appreciated!
edited Mar 22 at 16:06
Eric Fulmer
asked Mar 22 at 15:41
Eric FulmerEric Fulmer
3991315
3991315
Does the value you expect inVERSION_NUMBERat least make its way intoBASE_IMAGE_VERSION?
– hexacyanide
Mar 22 at 16:04
@hexacyanide Yes, this is same variable, I just made an error in my editing of the logs and operators. Fixing that now.
– Eric Fulmer
Mar 22 at 16:05
add a comment |
Does the value you expect inVERSION_NUMBERat least make its way intoBASE_IMAGE_VERSION?
– hexacyanide
Mar 22 at 16:04
@hexacyanide Yes, this is same variable, I just made an error in my editing of the logs and operators. Fixing that now.
– Eric Fulmer
Mar 22 at 16:05
Does the value you expect in
VERSION_NUMBER at least make its way into BASE_IMAGE_VERSION?– hexacyanide
Mar 22 at 16:04
Does the value you expect in
VERSION_NUMBER at least make its way into BASE_IMAGE_VERSION?– hexacyanide
Mar 22 at 16:04
@hexacyanide Yes, this is same variable, I just made an error in my editing of the logs and operators. Fixing that now.
– Eric Fulmer
Mar 22 at 16:05
@hexacyanide Yes, this is same variable, I just made an error in my editing of the logs and operators. Fixing that now.
– Eric Fulmer
Mar 22 at 16:05
add a comment |
1 Answer
1
active
oldest
votes
Turns out this was a misunderstanding of the logs!
When providing an environment variable to a Kubernetes pod via a Secret, that value key in the API response is None because the value comes from the secret_key_ref.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303229%2faccessing-kubernetes-secret-from-airflow-kubernetespodoperator%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Turns out this was a misunderstanding of the logs!
When providing an environment variable to a Kubernetes pod via a Secret, that value key in the API response is None because the value comes from the secret_key_ref.
add a comment |
Turns out this was a misunderstanding of the logs!
When providing an environment variable to a Kubernetes pod via a Secret, that value key in the API response is None because the value comes from the secret_key_ref.
add a comment |
Turns out this was a misunderstanding of the logs!
When providing an environment variable to a Kubernetes pod via a Secret, that value key in the API response is None because the value comes from the secret_key_ref.
Turns out this was a misunderstanding of the logs!
When providing an environment variable to a Kubernetes pod via a Secret, that value key in the API response is None because the value comes from the secret_key_ref.
answered Mar 22 at 16:54
Eric FulmerEric Fulmer
3991315
3991315
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303229%2faccessing-kubernetes-secret-from-airflow-kubernetespodoperator%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does the value you expect in
VERSION_NUMBERat least make its way intoBASE_IMAGE_VERSION?– hexacyanide
Mar 22 at 16:04
@hexacyanide Yes, this is same variable, I just made an error in my editing of the logs and operators. Fixing that now.
– Eric Fulmer
Mar 22 at 16:05