2017-08-02 7 views
0

私はTraefikをKubernetes 1.7.2クラスタに接続しています。私のクラスタはRBACを使用し、tomlのガイドにはrbacに関する情報は含まれていません。traefik tomlファイルでRBACを定義する

cat ~/.kube/config | grep client-certificate-data | tr -d ' ' | cut -d ":" -f2 | base64 -d 

とトークンを実行することによって:

kubectl get secrets default-token-mnxss -o jsonpath='{.data.token}' | base64 -d 

マイtomlのルックスを

は、私が実行している(と/root/projects/certs/ca.crtに入れる)ことにより、証明書を取得します次のように:

InsecureSkipVerify = true 

defaultEntryPoints = ["http", "https"] 

[entryPoints] 
[entryPoints.http] 
    address = ":80" 
[entryPoints.http.redirect] 
    entryPoint = "https" 
[entryPoints.https] 
    address = ":443" 
[entryPoints.https.tls] 

[[entryPoints.https.tls.certificates]] 
CertFile = "/certs/kubernetes.pem" 
KeyFile = "/certs/kubernetes-key.pem" 

[web] 
address = ":8080" 
ReadOnly = true 

[kubernetes] 
endpoint = "https://192.168.100.226:6443" 

token="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRlZmF1bHQtdG9rZW4tbW54c3MiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGVmYXVsdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImQxNjYxZWIyLTc1Y2EtMTFlNy1iY2Q4LTUyNTQwMDI2OGU5YSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OmRlZmF1bHQifQ.xHVMxmFm8e8SkfHQxaxh_UjocWeHr_GoAvkMfrZUyMrleqxj5LQg_fHfpaWNcKePF3AfLmDn7COILiPNAoknF9OqaQzSXRoch0i8omFIbTtf3d5fe7z3psHBCE827tdtnV_9VNejFWC6VWRhxmkHz6_9x1LeLvYWOXPet5_97A254UUvJVQouriq3Y9GqIZiWdCIzU4yC9wQbYCG5s_Sy9pVELsRAGuVNYMA6-UH4rjUDrtn0fBxah89XjBlqJ8FB1darByqmY0Ws-3IX6AB1PGPKrQdz9kI2Yzg_ftobUJNcjM3oeQ4acx4EO9zu_5WMl7PnrVfO3tWZHHXRa-6IA" 

certAuthFilePath = "/root/projects/certs/ca.crt" 

# Kubernetes server endpoint 
#endpoint = "http://localhost:8001" 
#endpoint = "https://192.168.100.226:6443" 
#namespaces = ["default","kube-system"] 

私はまだ取得:

ERROR: logging before flag.Parse: E0804 04:02:54.161007 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Service: the server does not allow access to the requested resource (get services) 
ERROR: logging before flag.Parse: E0804 04:02:54.161070 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1beta1.Ingress: the server does not allow access to the requested resource (get ingresses.extensions) 
ERROR: logging before flag.Parse: E0804 04:02:54.161089 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Endpoints: the server does not allow access to the requested resource (get endpoints) 
ERROR: logging before flag.Parse: E0804 04:02:54.162291 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Secret: the server does not allow access to the requested resource (get secrets) 
ERROR: logging before flag.Parse: E0804 04:02:55.174304 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Secret: the server does not allow access to the requested resource (get secrets) 
ERROR: logging before flag.Parse: E0804 04:02:55.174399 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Service: the server does not allow access to the requested resource (get services) 
ERROR: logging before flag.Parse: E0804 04:02:55.174474 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Endpoints: the server does not allow access to the requested resource (get endpoints) 
ERROR: logging before flag.Parse: E0804 04:02:55.176349 12874 reflector.go:199] github.com/containous/traefik/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1beta1.Ingress: the server does not allow access to the requested resource (get ingresses.extensions) 

答えて

0

サービスアカウント名は、TOML設定には含まれませんが、Deployment/DaemonSetマニフェストの仕様に含まれます。

Traefik guideが例です。この例では、あなたが名前traefik-ingress-controllerおよび結合した適切なRBACによって、サービスアカウントを設定していると仮定していること

kind: Deployment 
apiVersion: extensions/v1beta1 
spec: 
    template: 
    spec: 
     serviceAccountName: traefik-ingress-controller 

注:以下は、サービスアカウント名がインデントワイズを行く必要の展開が見ためだけの最低限のYAMLですそれにルールを当てる。このガイドはまた、両方のための追加の一貫したマニフェストを提供します。

クラスタ外でTraefikを実行する場合は、3つのパラメータendpoint,token、およびcertAuthFilePathを設定する必要があります。トークンは、Kubernetesが自動的に作成するサービスアカウントの秘密に関連付けられたものでなければなりません。

  1. kubectl get secrets --namespace=<the service account's namespace>からサービスアカウントの秘密の名前を特定します。
  2. トークンを抽出します(秘密はすべてbase64エンコードされているので、デコードする必要があります)。kubectl get secrets <the service account's secret> --namespace=<the service account's namespace> -o jsonpath='{.data.token}' | base64 -D

最後に、そのトークンをTOML設定ファイルに設定します。

同様に秘密オブジェクトからCA証明書を取得できます。しかし、公開されており、クラスタの管理コンソールや$HOME/.kube/configのように、他の場所から簡単にアクセスできます。

+0

Thanks @ timo-reimann 私は展開のserviceAccountNameについて知っていますが、私のKubernetesクラスタ内ではtraefikを実行していません。私は外でそれを実行しています。だから私は配備やデーモンセットを持っていない。マスターに接続するにはtraefikが必要で、私のクラスタ内で作成したサービスアカウントを使用します。しかし、私はどのようにドキュメントで見ることができません。 –

+0

申し訳ありませんが、わかりませんでした。私はあなたのサービスアカウントの秘密からトークンを抽出する方法を説明するために私の答えを拡張しました。 –

+0

こんにちは$ timo-reimannです。あなたが書いたことを試しましたが、運がありません。 トップポストを更新しました。クラスターはラップトップのテストクラスターなので、証明書がオンラインになっているかどうかは、それほど重要ではありません。 –

関連する問題