2017-10-07 156 views
0

我已成功部署到Azure的羣集。現在試圖設置kubectl來處理它。連接到Azure ACS羣集的Kubectl

運行:

az acs kubernetes get-credentials --resource-group=group --name=cluster 

結果:

scp: .kube/config: No such file or directory 
Traceback (most recent call last): 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/main.py", line 36, in main 
    cmd_result = APPLICATION.execute(args) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/application.py", line 212, in execute 
    result = expanded_arg.func(params) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__ 
    return self.handler(*args, **kwargs) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 626, in _execute_command 
    reraise(*sys.exc_info()) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 603, in _execute_command 
    result = op(client, **kwargs) if client else op(**kwargs) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acs/custom.py", line 814, in k8s_get_credentials 
    _k8s_get_credentials_internal(name, acs_info, path, ssh_key_file) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acs/custom.py", line 835, in _k8s_get_credentials_internal 
    '.kube/config', path_candidate, key_filename=ssh_key_file) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acs/acs_client.py", line 64, in secure_copy 
    scp.get(src, dest) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/scp.py", line 198, in get 
    self._recv_all() 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/scp.py", line 348, in _recv_all 
    raise SCPException(asunicode(msg[1:])) 
SCPException: scp: .kube/config: No such file or directory 

文件~/.kube/config存在,並且我可以ssh到羣集的主節點。

不知道我在做什麼可能是錯的?

UPDATE。

每試過這裏的意見,一個運行命令:

az acs kubernetes get-credentials --resource-group=group --name=cluster -f /Users/me/.kube/config --debug 

並取得了以下信息:

Password for private key: 
paramiko.transport : starting thread (client mode): 0x9659890L 
paramiko.transport : Local version/idstring: SSH-2.0-paramiko_2.3.1 
paramiko.transport : Remote version/idstring: SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 
paramiko.transport : Connected (version 2.0, client OpenSSH_7.2p2) 
paramiko.transport : kex algos:[u'[email protected]', u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group14-sha1'] server key:[u'ssh-rsa', u'rsa-sha2-512', u'rsa-sha2-256', u'ecdsa-sha2-nistp256', u'ssh-ed25519'] client encrypt:[u'[email protected]', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'[email protected]', u'[email protected]'] server encrypt:[u'[email protected]', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'[email protected]', u'[email protected]'] client mac:[u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] server mac:[u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] client compress:[u'none', u'[email protected]'] server compress:[u'none', u'[email protected]'] client lang:[u''] server lang:[u''] kex follows?False 
paramiko.transport : Kex agreed: ecdh-sha2-nistp256 
paramiko.transport : HostKey agreed: ecdsa-sha2-nistp256 
paramiko.transport : Cipher agreed: aes128-ctr 
paramiko.transport : MAC agreed: hmac-sha2-256 
paramiko.transport : Compression agreed: none 
paramiko.transport : kex engine KexNistp256 specified hash_algo <built-in function openssl_sha256> 
paramiko.transport : Switch to new keys ... 
paramiko.transport : Trying SSH key 765f702f5fff7fe30260d53b5bbb57eb 
paramiko.transport : userauth is OK 
paramiko.transport : Authentication (publickey) successful! 
paramiko.transport : [chan 0] Max packet in: 32768 bytes 
paramiko.transport : Received global request "[email protected]" 
paramiko.transport : Rejecting "[email protected]" global request from server. 
paramiko.transport : [chan 0] Max packet out: 32768 bytes 
paramiko.transport : Secsh channel 0 opened. 
paramiko.transport : [chan 0] Sesch channel 0 request ok 
paramiko.transport : [chan 0] EOF received (0) 
paramiko.transport : [chan 0] EOF sent (0) 
scp: .kube/config: No such file or directory 
Traceback (most recent call last): 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/main.py", line 36, in main 
    cmd_result = APPLICATION.execute(args) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/application.py", line 212, in execute 
    result = expanded_arg.func(params) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__ 
    return self.handler(*args, **kwargs) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 626, in _execute_command 
    reraise(*sys.exc_info()) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 603, in _execute_command 
    result = op(client, **kwargs) if client else op(**kwargs) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acs/custom.py", line 814, in k8s_get_credentials 
    _k8s_get_credentials_internal(name, acs_info, path, ssh_key_file) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acs/custom.py", line 835, in _k8s_get_credentials_internal 
    '.kube/config', path_candidate, key_filename=ssh_key_file) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/azure/cli/command_modules/acs/acs_client.py", line 64, in secure_copy 
    scp.get(src, dest) 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/scp.py", line 198, in get 
    self._recv_all() 
    File "/Users/me/lib/azure-cli/lib/python2.7/site-packages/scp.py", line 348, in _recv_all 
    raise SCPException(asunicode(msg[1:])) 
SCPException: scp: .kube/config: No such file or directory 

蔚藍CLI的版本是2.0.18。希望建議。

回答

0

嘗試使用--file -f標誌指定.kube目錄中「config」文件的絕對路徑,您可以使用--debug進行進一步調試。

az acs kubernetes get-credentials --resource-group=group --name=cluster -f /.../.../.kube/config --debug

+0

謝謝,我會盡力 – experimenter

+0

我試過了並更新了我的問題。如果你看一看,我會非常感激! – experimenter

+0

我試圖讓我的羣集被添加到〜/ .kube/config,而他的憑證命令似乎是這樣,但對我來說卻失敗了。還試圖用Python 3.6來做這件事,但仍然是同樣的錯誤。 – experimenter

0

在我的情況下,.kube/config文件並沒有在主創建。嘗試創建.kube/config文件時發生錯誤,我通過ssh注意到了我的主節點並查看了/ var/log/azure目錄。該錯誤與我的服務主體密碼有關。有了新的服務負責人,新的羣集運行得很好。