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

Problem with RBAC? #15

Open
fzerorubigd opened this issue Aug 27, 2017 · 2 comments
Open

Problem with RBAC? #15

fzerorubigd opened this issue Aug 27, 2017 · 2 comments

Comments

@fzerorubigd
Copy link

Failed with RBAC enabled cluster (1.7 in my case)
fluentd-elasticsearch is failed with this :

2017-08-27 10:20:21 +0000 [error]: config error file="/etc/td-agent/td-agent.conf" error="Exception encountered fetching metadata from Kubernetes API endpoint: 403 Forbidden"
2017-08-27 10:20:21 +0000 [warn]: process died within 1 second. exit.

The only thing I change is Namespace (via NAMESPACE env) .

@polasekr
Copy link

Create following authorization in kubernetes and run the container with the service account specified.

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: fluentd
  namespace: system

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: fluentd
  namespace: system
rules:
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - get
  - list
  - watch

---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: fluentd
roleRef:
  kind: ClusterRole
  name: fluentd
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: fluentd
  namespace: system

In order to run deamonset under fluentd account you need to add clause serviceAccountName to fluentd yaml file:

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: fluentd-elasticsearch
  labels:
    k8s-app: fluentd-logging
spec:
  template:
    metadata:
      labels:
        k8s-app: fluentd-logging
        name: fluentd-logging
    spec:
      containers:
      - name: fluentd-elasticsearch
        image: kayrus/fluentd-elasticsearch:1.20
        imagePullPolicy: Always
        # suppress "info" log level
        args:
          - -q
        resources:
          limits:
            memory: 1024Mi
          requests:
            cpu: 100m
            memory: 1024Mi
        volumeMounts:
        - name: var-log
          mountPath: /var/log
        - name: run-log
          mountPath: /run/log
        - name: var-lib-docker-containers
          mountPath: /var/lib/docker/containers
          readOnly: true
        - name: localdata-docker-containers
          mountPath: /localdata/docker/containers
          readOnly: true
        - name: fluentd-config
          mountPath: /etc/td-agent
          readOnly: true
      terminationGracePeriodSeconds: 30
      serviceAccountName: fluentd
      volumes:
      - name: var-log
        hostPath:
          path: /var/log
      - name: run-log
        hostPath:
          path: /run/log
      - name: var-lib-docker-containers
        hostPath:
          path: /var/lib/docker/containers
      - name: localdata-docker-containers
        hostPath:
          path: /localdata/docker/containers
      - name: fluentd-config
        configMap:
           name: fluentd-config

@kayrus
Copy link
Owner

kayrus commented Sep 11, 2017

@polasekr thank you for a tip. However I'm aware about this issue and there is a pull request. #12

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

No branches or pull requests

3 participants