---
# System prepended metadata

title: ユーザー周りの理解

---

# ユーザー周りの理解
## リモートのk8sを扱う

基本的にユーザーはsshを使うのではなくlocalのkubectlコマンドアクセスしてデバックや動作確認やテストを行うことにする

今回はadminのままやる
ユーザーごとにuserを作ってアクセスできる様にするのが理想 -> 調査

```
# リモートから扱う情報を取得
$ kubectl config view --raw

# localの~/.kube/configに設定していく
$ vim ~/.kube/config

# 取得した情報を実際に設定したらこんな感じ
apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://localhost:6443
  name: docker-for-desktop-cluster
# 追記
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFNU1EY3lPVEV5TVRJeU1Gb1hEVEk1TURjeU5qRXlNVEl5TUZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTURqCjNIUFlTWXFhaGRIclBpMmluZlBtUjZGdTVsTmVhalFDbFNIemZPZGo4dVpHczB2aFJoT2w0RHlnWnpoVEo0ajgKT0crZDFPTXdPV2s2WTN6MkE2RitQTU5mK2NRRnpxdk1xbGlmY21vQTlXaUFRanFmYlVLb0FhcXBDMkJkNDhhLworNy9jTW5OMGhVSTJBUVhYRVl5VlF3R2tMUTF6WE91d0NUTnp6NXllNCtGSzc4b0FscHlKVVVZdzBoMHp3UFdtClJPeFNkQVNPQnZ6NXVOdzJPOSs4U0FjaXhTOVJLUk90ZDI2dHRrdTU1VjRMQ3J2Q1dJTUwxNVZYVUgrQml6R2sKQmhpQ1VnaTY0U1cyZ2JSdkJLVnFrQklwV2dza0tuVUZPMU9STnNGaDIxd01qM0ZTWFZKcEhaeHZOQjh5ck1qQQp5NlNKVzczdkwrOURpUU5ISmFFQ0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFEY256bU5sTldnYXNtcGxjTHlweU5wd1h3KzUKdkE0ZzBlTzVNcCttTS82cG9Oek1aN1VZam9qbE1EWXdUOS9uWHYrNEJDN0VDUUE5NThyM2VvRGg1SWIyd0FIWgoySHVRWDgwYTROY0lIMkhyTmlWeHUwQm9Pa1JtWGc1YWVqN0YrRzVzVGJXQk1BeWhQUTQwMDhVYVJoQmw3ZkgvCmVOamJHZVpKQTRQV1hFa1FKZzhSSCt6aXJKNjVQNzlmS1d5d0ozbmt4T1RqQ0Q1UWhDYVhpWlFMQUhPL21EdGYKRm9GRXhlZUpQQWtwZjVUaXIzdE5xQ1g4U2kyM2d4dnNrbDFBV2EySndjQzEyM2ExeEp5dTVxcU9VTStLK2dGVgpwZHU0dFdEaGJpOXpreUFEMXNHRkFxamJZdDMzSTJvMlcydE1ZQThVbFNqQS9WL0JlanM4NVlSejFkdz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
    server: https://10.50.0.151:6443
  name: kubernetes

contexts:
- context:
    cluster: docker-for-desktop-cluster
    user: docker-for-desktop
  name: docker-for-desktop
# 追記
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-test
  
current-context: kubernetes-test
kind: Config
preferences: {}
users:
- name: docker-for-desktop
  user:
    client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM5RENDQWR5Z0F3SUJBZ0lJTVJZREd5VnlOeVV3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBeU1UTXhNekV3TkRoYUZ3MHlNREEzTWpVd01ETTROVFJhTURZeApGekFWQmdOVkJBb1REbk41YzNSbGJU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