Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl apply -f doesn't work #369

Closed
antonioluzzi opened this issue Aug 8, 2023 · 3 comments · Fixed by #403
Closed

kubectl apply -f doesn't work #369

antonioluzzi opened this issue Aug 8, 2023 · 3 comments · Fixed by #403

Comments

@antonioluzzi
Copy link

Hi,
I'm trying to install the reflector without success on my k8s cluster (v1.27.4).
When I use the following command:

kubectl -n kube-system apply -f https://github.com/emberstack/kubernetes-reflector/releases/latest/download/reflector.yaml

I'll get:
the namespace from the provided object "default" does not match the namespace "kube-system". You must pass '--namespace=default' to perform this operation.

I can install only in the default namespace, but It doesn't work when I deploy my secret with the following annotation:
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "dev-1,dev-2,dev-[0-9]*"

@antonioluzzi
Copy link
Author

I have solved to modify yaml file:

`apiVersion: v1
kind: ServiceAccount
metadata:
name: reflector
namespace: kube-system
labels:
helm.sh/chart: reflector-7.0.193
app.kubernetes.io/name: reflector
app.kubernetes.io/instance: reflector
app.kubernetes.io/version: "7.0.193"
app.kubernetes.io/managed-by: Helm
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: reflector
namespace: kube-system
labels:
helm.sh/chart: reflector-7.0.193
app.kubernetes.io/name: reflector
app.kubernetes.io/instance: reflector
app.kubernetes.io/version: "7.0.193"
app.kubernetes.io/managed-by: Helm
rules:

  • apiGroups: [""]
    resources: ["configmaps", "secrets"]
    verbs: ["*"]
  • apiGroups: [""]
    resources: ["namespaces"]
    verbs: ["watch", "list"]
  • apiGroups: ["apiextensions.k8s.io"]
    resources: ["customresourcedefinitions"]
    verbs: ["watch", "list"]
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
    name: reflector
    namespace: kube-system
    labels:
    helm.sh/chart: reflector-7.0.193
    app.kubernetes.io/name: reflector
    app.kubernetes.io/instance: reflector
    app.kubernetes.io/version: "7.0.193"
    app.kubernetes.io/managed-by: Helm
    roleRef:
    kind: ClusterRole
    name: reflector
    apiGroup: rbac.authorization.k8s.io
    subjects:
  • kind: ServiceAccount
    name: reflector
    namespace: kube-system
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: reflector
    namespace: kube-system
    labels:
    helm.sh/chart: reflector-7.0.193
    app.kubernetes.io/name: reflector
    app.kubernetes.io/instance: reflector
    app.kubernetes.io/version: "7.0.193"
    app.kubernetes.io/managed-by: Helm
    spec:
    replicas: 1
    selector:
    matchLabels:
    app.kubernetes.io/name: reflector
    app.kubernetes.io/instance: reflector
    template:
    metadata:
    labels:
    app.kubernetes.io/name: reflector
    app.kubernetes.io/instance: reflector
    spec:
    serviceAccountName: reflector
    securityContext:
    fsGroup: 2000
    containers:
    - name: reflector
    securityContext:
    capabilities:
    drop:
    - ALL
    readOnlyRootFilesystem: false
    runAsNonRoot: true
    runAsUser: 1000
    image: "emberstack/kubernetes-reflector:7.0.193"
    imagePullPolicy: IfNotPresent
    env:
    - name: ES_Serilog__MinimumLevel__Default
    value: "Information"
    - name: ES_Reflector__Watcher__Timeout
    value: ""
    ports:
    - name: http
    containerPort: 25080
    protocol: TCP
    livenessProbe:
    httpGet:
    path: /healthz
    port: http
    initialDelaySeconds: 5
    periodSeconds: 10
    readinessProbe:
    httpGet:
    path: /healthz
    port: http
    initialDelaySeconds: 5
    periodSeconds: 10
    resources:
    {}
    `

@jvasquezv
Copy link

x2 :(

@sh-cho
Copy link

sh-cho commented Sep 21, 2023

$ wget -q -O - https://github.com/emberstack/kubernetes-reflector/releases/latest/download/reflector.yaml \
   | sed -E 's/([[:space:]]*namespace:[[:space:]]*)default/\1kube-system/' \
   | kubectl -n kube-system apply -f -

Same here. Just workaround with sed, which replaces all namespace: default to namespace: kube-system

$ wget -q -O - https://github.com/emberstack/kubernetes-reflector/releases/latest/download/reflector.yaml \
   | sed -E 's/([[:space:]]*namespace:[[:space:]]*)default/\1kube-system/' \
   | kubectl -n kube-system apply --dry-run=client -f -

Check with dry-run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants