<p>I have below k8s configuration yml file but when run <code>kubectl apply</code>, it gives me the error <code> namespaces &quot;aws-observability&quot; not found</code>.</p>
<p>I understand that the <code>aws-observability</code> namespace is not deployed when deploying the <code>ConfigMap</code>.</p>
<p>It can be solved by split this config to two files and deploy the <code>namespace</code> first then the <code>ConfigMap</code>. But I'd like to put them in one file and deploy them in one go. How can I add a <code>depend</code> between these two configurations?</p>
<pre class="lang-yaml prettyprint-override"><code>kind: Namespace
apiVersion: v1
metadata:
  name: aws-observability
  labels:
    aws-observability: enabled

kind: ConfigMap
apiVersion: v1
metadata:
  name: aws-logging
  namespace: aws-observability
  labels:
data:
  output.conf: |
    [OUTPUT]
        Name cloudwatch
        Match   *
        region &lt;ap-southeast-2&gt;
        log_group_name elk-fluent-bit-cloudwatch
        log_stream_prefix from-elk-fluent-bit-
        auto_create_group true
</code></pre>

Joey Yi Zhao
<p>You should add separator (---) between two components. I have tested below YAML on my machine and its working as expected:</p>
<pre><code>kind: Namespace
apiVersion: v1
metadata:
  name: aws-observability
  labels:
    aws-observability: enabled
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: aws-logging
  namespace: aws-observability
  labels:
data:
  output.conf: |
    [OUTPUT]
        Name cloudwatch
        Match   *
        region &lt;ap-southeast-2&gt;
        log_group_name elk-fluent-bit-cloudwatch
        log_stream_prefix from-elk-fluent-bit-
        auto_create_group true
</code></pre>
