容器化参考文档
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.6 KiB

3 years ago
  1. how-to-get-kubectl-bin.md
  2. ----------------------
  3. ```
  4. @version 180902:1
  5. @author zhangxuhong <zhangxuhong@xitu.io>
  6. ```
  7. # desc
  8. ------
  9. 如何获取 kubectl 二进制文件.
  10. # main
  11. ------
  12. - 下载
  13. 根据 kubernetes 文档 [https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl)
  14. 我们得到 Centos 的 kubectl yum 源在: [https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64](https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64)
  15. 我们打开 https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/primary.xml 文件, 按照版本寻找我们要的 kubectl 下载地址.
  16. ```
  17. <package type="rpm">
  18. <name>kubectl</name>
  19. <arch>x86_64</arch>
  20. <version epoch="0" ver="1.11.2" rel="0"/>
  21. <checksum type="sha256" pkgid="YES">
  22. a554c1728ecf79871b4d3e0fc797568e53149f4ed7ec7e437c949a02f197a1ab
  23. </checksum>
  24. <summary>
  25. Command-line utility for interacting with a Kubernetes cluster.
  26. </summary>
  27. <description>
  28. Command-line utility for interacting with a Kubernetes cluster.
  29. </description>
  30. <packager/>
  31. <url>https://kubernetes.io</url>
  32. <time file="0" build="1533926010"/>
  33. <size package="7861358" installed="38728168" archive="38728420"/>
  34. <location href="../../pool/a554c1728ecf79871b4d3e0fc797568e53149f4ed7ec7e437c949a02f197a1ab-kubectl-1.11.2-0.x86_64.rpm"/>
  35. <format>
  36. <rpm:license>ASL 2.0</rpm:license>
  37. <rpm:vendor/>
  38. <rpm:group>Unspecified</rpm:group>
  39. <rpm:buildhost>1233039dde1f</rpm:buildhost>
  40. <rpm:sourcerpm>kubelet-1.11.2-0.src.rpm</rpm:sourcerpm>
  41. <rpm:header-range start="4424" end="8894"/>
  42. <rpm:provides>
  43. <rpm:entry name="kubectl" flags="EQ" epoch="0" ver="1.11.2" rel="0"/>
  44. <rpm:entry name="kubectl(x86-64)" flags="EQ" epoch="0" ver="1.11.2" rel="0"/>
  45. </rpm:provides>
  46. <file>/usr/bin/kubectl</file>
  47. </format>
  48. </package>
  49. ```
  50. 可以看到
  51. ```
  52. <location href="../../pool/a554c1728ecf79871b4d3e0fc797568e53149f4ed7ec7e437c949a02f197a1ab-kubectl-1.11.2-0.x86_64.rpm"/>
  53. ```
  54. 即为下载地址. 我们拼接url得到下载地址为:
  55. https://packages.cloud.google.com/yum/pool/a554c1728ecf79871b4d3e0fc797568e53149f4ed7ec7e437c949a02f197a1ab-kubectl-1.11.2-0.x86_64.rpm
  56. - 解压 rpm 包.
  57. 下载 rpm 包后, 解压即可得到我们需要的 kubectl 二进制文件.
  58. 解压需要 rpm2cpio 程序. 这个程序是 rpm 包自带的, 不需要安装.
  59. ```
  60. wget https://packages.cloud.google.com/yum/pool/a554c1728ecf79871b4d3e0fc797568e53149f4ed7ec7e437c949a02f197a1ab-kubectl-1.11.2-0.x86_64.rpm
  61. rpm2cpio a554c1728ecf79871b4d3e0fc797568e53149f4ed7ec7e437c949a02f197a1ab-kubectl-1.11.2-0.x86_64.rpm | cpio -idmv
  62. ```
  63. 解压后就是了.