2017-04-07 15 views
3

私は1.6に私のGKEのAPIサーバーをアップグレード、および1.6にノードをアップグレードする過程でですが、思わぬ障害に走った...プロメテウス - Kubernetes RBAC

私はプロメテウスサーバー(バージョン1.5を持っています。 2)バージョン1.5.4のKubeletを実行しているいくつかのノードを持つKubernetesの配備で管理されているポッドで実行され、1.6の新しいノードが1つ実行されます。

プロメテウスは新しいノードに接続できません - メトリックエンドポイントは401 Unauthorizedを返しています。

これはRBACの問題だと思われますが、どのように進めるかはわかりません。私はプロメテウスのサーバーが必要とする役割や、サーバーにそれらを与える方法についてのドキュメントを見つけることはできません。私は一緒に私は仕事に期待するかもしれない設定をつなぎすることができましたcoreos /プロメテウス - オペレーターレポから

apiVersion: v1 
kind: ServiceAccount 
metadata: 
    name: prometheus 
--- 

apiVersion: rbac.authorization.k8s.io/v1beta1 
kind: ClusterRole 
metadata: 
    name: prometheus 
rules: 
- apiGroups: [""] 
    resources: 
    - nodes 
    - services 
    - endpoints 
    - pods 
    verbs: ["get", "list", "watch"] 
- apiGroups: [""] 
    resources: 
    - configmaps 
    verbs: ["get"] 
- nonResourceURLs: ["/metrics"] 
    verbs: ["get"] 
--- 

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

apiVersion: v1 
kind: ServiceAccount 
metadata: 
    name: prometheus 
    namespace: default 
secrets: 
- name: prometheus-token-xxxxx 

--- 
apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
    labels: 
    app: prometheus-prometheus 
    component: server 
    release: prometheus 
    name: prometheus-server 
    namespace: default 
spec: 
    replicas: 1 
    selector: 
    matchLabels: 
     app: prometheus-prometheus 
     component: server 
     release: prometheus 
    strategy: 
    rollingUpdate: 
     maxSurge: 1 
     maxUnavailable: 1 
    type: RollingUpdate 
    template: 
    metadata: 
     labels: 
     app: prometheus-prometheus 
     component: server 
     release: prometheus 
    spec: 
     dnsPolicy: ClusterFirst 
     restartPolicy: Always 
     schedulerName: default-scheduler 
     serviceAccount: prometheus 
     serviceAccountName: prometheus 
     ... 

しかし、プロメテウスはまだ401Sを得ています。

UPDATE:ジョーダン氏によると、kubernetes認証の問題のようだ。新しい、より焦点を絞った質問をここで見てください。 https://serverfault.com/questions/843751/kubernetes-node-metrics-endpoint-returns-401

答えて

0

@ JorritSalverdaのチケットに関する議論に従って、 https://github.com/prometheus/prometheus/issues/2606#issuecomment-294869099

GKEでは、kubeletで自分自身を認証できるクライアント証明書にアクセスできないため、GKE上のユーザーにとって最適なソリューションは、kubernetes APIサーバーをノードへのプロキシ要求として使用するようです。

これを行うには(引用@ JorritSalverda);

relabel_configs: 
- action: labelmap 
    regex: __meta_kubernetes_node_label_(.+) 
- target_label: __address__ 
    replacement: kubernetes.default.svc.cluster.local:443 
- target_label: __scheme__ 
    replacement: https 
- source_labels: [__meta_kubernetes_node_name] 
    regex: (.+) 
    target_label: __metrics_path__ 
    replacement: /api/v1/nodes/${1}/proxy/metrics 

そして、プロメテウスが使用するサービスアカウントにバインドされ、次のClusterRole:

apiVersion: rbac.authorization.k8s.io/v1beta1 
kind: ClusterRole 
metadata: 
    name: prometheus 
rules: 
- apiGroups: [""] 
    resources: 
    - nodes 
    - nodes/proxy 
    - services 
    - endpoints 
    - pods 
    verbs: ["get", "list", "watch"] 

ので、私のプロメテウスの私は、今では、次の再ラベル付けを実行しているGKE内で実行しているサーバーの場合

」 RBACが失敗した場合でもGKEクラスタにはABACフォールバックがあります。これは100%保証されていませんが、これはすべての必要な権限をカバーしています。

2

401は、認証されていないことを意味します。つまり、RBACの問題ではありません。私はGKEが1.6でkubeletへの匿名アクセスを許可しなくなったと思います。 kubeletの認証にどの資格情報を使用していますか?

+0

ねえジョーダン!うん、それはまったく問題ですが、私はそれを認証する方法がわかりません。私は最後の1時間、Coreos/prometheus-operatorレポから何かをまとめて作業しています。私は自分の持っているもので質問を更新しました。 ありがとう! – pnovotnak

+0

@ jordan-liggitt匿名アクセスの削除に関する情報源がありますか?私はOPと同じ問題に直面している – CNevin561

+0

私の場合は、一般的に認証の問題のように見える、とジョーダンは言った。 'curl -vsSk -H '権限:ベアラ$(サービスアカウントを使用するように設定されている、配備によって管理されている)同じポッドのコンテナ内のエンドポイントを手動で' /var/run/secrets/kubernetes.io/serviceaccount/token) "https:// $ NODE_IP:10250/metrics' 私は' HTTP/1.1 401 Unauthorized'を取得します。 – pnovotnak

0

役割の定義とバインディングのために働いています。

apiVersion: rbac.authorization.k8s.io/v1beta1 
 
kind: ClusterRole 
 
metadata: 
 
    name: prometheus 
 
rules: 
 
- apiGroups: [""] 
 
    resources: 
 
    - nodes 
 
    - services 
 
    - endpoints 
 
    - pods 
 
    verbs: ["get", "list", "watch"] 
 
- nonResourceURLs: ["/metrics"] 
 
    verbs: ["get"] 
 
--- 
 
apiVersion: v1 
 
kind: ServiceAccount 
 
metadata: 
 
    name: prometheus 
 
    namespace: default 
 
--- 
 
apiVersion: rbac.authorization.k8s.io/v1beta1 
 
kind: ClusterRoleBinding 
 
metadata: 
 
    name: prometheus 
 
roleRef: 
 
    apiGroup: rbac.authorization.k8s.io 
 
    kind: ClusterRole 
 
    name: prometheus 
 
subjects: 
 
- kind: ServiceAccount 
 
    name: prometheus 
 
    namespace: default

関連する問題