Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl apply -k throws Error: rawResources failed to read Resources: Load from path ../../base failed: '../../base' must be a file

Can you please help me figure out why kubectl apply fails? When I try to run kubectl apply -k k8s/overlays/dev it fails with error message "error: rawResources failed to read Resources: Load from path ../../base failed: '../../base' must be a file" But if I run kustomize build k8s/overlays/dev it works fine.

folder structure

|____k8s
| |____overlays
| | |____dev
| | | |____kustomization.yaml
| |____base
| | |____deployment.yaml
| | |____kustomization.yaml

k8s/base/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1
  template:
    spec:
      containers:
        - name: my-app
          image: my-app:v1
          ports:
            - containerPort: 8080
              protocol: TCP

k8s/base/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml

commonLabels:
  app: my-app

k8s/overlays/dev/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base

like image 984
Aleksandras Artemjevas Avatar asked Apr 13 '21 09:04

Aleksandras Artemjevas


People also ask

How to ignore kubectl error validation?

error: error validating "kustomization.yml": error validating data: [apiVersion not set, kind not set ]; if you choose to ignore these errors, turn validation off with --validate= false kubectl apply -k .:

What is kubectl apply in Kubernetes?

Kubectl apply apply manages applications through files defining Kubernetes resources. It creates and updates resources in a cluster through running kubectl apply. This is the recommended way of managing Kubernetes applications on production.

How do I debug kubectl output verbosity?

Kubectl output verbosity and debugging Kubectl verbosity is controlled with the -v or --v flags followed by an integer representing the log level. General Kubernetes logging conventions and the associated log levels are described here.

What is kubectl wait-experimental?

kubectl wait - Experimental: Wait for a specific condition on one or many resources. Was this page helpful? Thanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on Stack Overflow .


1 Answers

Upgrading kubectl to v1.21.0 solved the issue.

like image 199
Aleksandras Artemjevas Avatar answered Oct 19 '22 04:10

Aleksandras Artemjevas