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
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 .:
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.
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.
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 .
Upgrading kubectl to v1.21.0 solved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With