<p>I was trying to use a module in airflow called Secrets to pass secrets to KubernetesOperator in Airflow.
It should be imported as <code>from airflow.contrib.kubernetes.secret import Secret</code></p>
<p>But I'm getting an error
<code>ModuleNotFoundError: No module named 'airflow.contrib.kubernetes'</code></p>
<p>I have tried to install apache-airflow kubernetes package <code>pip install apache-airflow[kubernetes]</code>
but this did not help.</p>

Kavya
<p>The import is:</p>
<pre><code>from airflow.kubernetes.secret import Secret
</code></pre>
<p>Note that the Secret class in Airflow can only <strong>reference</strong> secrets already exist in Kubernetes.</p>
<p>If you are looking to &quot;pass&quot; = generate secrets then it won't work. You first must create them in Kubernetes. You can do this by using <code>create_namespaced_secret</code> of the Kubernetes Python SDK - see <a href="https://stackoverflow.com/questions/61405562/using-create-namespaced-secret-api-in-kubernetes-python-client">Using create_namespaced_secret API in Kubernetes Python client</a></p>
<p>Noting that there is <a href="https://github.com/apache/airflow/issues/28086" rel="nofollow noreferrer">open feature request</a> to be able to use credentials passed from Airflow Connections to the POD running the workload.</p>
