{"id":4510,"date":"2023-02-21T14:58:59","date_gmt":"2023-02-21T06:58:59","guid":{"rendered":"https:\/\/km94.com\/?p=4510"},"modified":"2023-02-21T14:58:59","modified_gmt":"2023-02-21T06:58:59","slug":"vultr-kubernetes%e5%bc%95%e6%93%8e%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%aegitlab-runner%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/dy208.cn\/index.php\/2023\/02\/21\/vultr-kubernetes%e5%bc%95%e6%93%8e%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%aegitlab-runner%e6%95%99%e7%a8%8b\/","title":{"rendered":"Vultr Kubernetes\u5f15\u64ce\u5b89\u88c5\u914d\u7f6eGitLab Runner\u6559\u7a0b"},"content":{"rendered":"<p>GitLab Runner\u662f\u4e00\u4e2a\u5f00\u6e90\u8f6f\u4ef6\u7cfb\u7edf\uff0c\u8fd0\u884cCI\/CD\u4f5c\u4e1a\uff0c\u5e76\u5c06\u7ed3\u679c\u53d1\u9001\u5230GitLab\u3002GitLab\u4e2d\u7684\u6bcf\u4e2a\u9879\u76ee\u90fd\u53ef\u4ee5\u6709\u81ea\u5df1\u7684\u8fd0\u884c\u5668\uff0c\u6bcf\u4e2a\u8fd0\u884c\u5668\u90fd\u662f\u4e00\u4e2a\u5bb9\u5668\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u542f\u52a8\u548c\u505c\u6b62\u3002\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u4e0b\u5982\u4f55\u5728Vultr Kubernetes\u5f15\u64ce\u4e0a\u5b89\u88c5\u914d\u7f6eGitLab Runner\u3002<\/p>\n<p><strong>\u4e00\u3001\u8bbe\u7f6eGitLab Runner<\/strong><\/p>\n<p>\u5728GitLab\u9879\u76ee\u76ee\u5f55\u4e2d\uff0c\u70b9\u51fbSettings &gt; CI\/CD &gt; Runners\uff0c\u83b7\u53d6runner\u4fe1\u606f\uff0c\u7528\u6765\u5411GitLab\u8ba4\u8bc1runner\u3002\u590d\u5236runner URL\u548c\u6ce8\u518c\u5bc6\u7801\uff0c\u5e76\u4fdd\u5b58\u5b83\u4eec\u4ee5\u4fbf\u540e\u7eed\u4f9bGitLab Runner\u914d\u7f6e\u4f7f\u7528\u3002<\/p>\n<p>\n\t<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-4512\" alt=\"\u8bbe\u7f6eGitLab Runner\" src=\"https:\/\/km94.com\/wp-content\/uploads\/2023\/02\/git1-2.jpg\"><\/figure>\n\t<\/p>\n<p><strong>\u4e8c\u3001\u5728Vultr Kubernetes Engine\u4e0a\u5b89\u88c5GitLab Runner<\/strong><\/p>\n<p>\u6211\u4eec\u8981\u5728Vultr Kubernetes Engine\u96c6\u7fa4\u4e0a\u90e8\u7f72Runner\u7684\u8bdd\uff0c\u5219\u9700\u4f7f\u7528kubeconfig\u6587\u4ef6\u6765\u914d\u7f6e\u5bf9\u96c6\u7fa4\u7684\u8bbf\u95ee\u3002kubeconfig\u6587\u4ef6\u7528\u4e8e\u63d0\u4f9b\u5bf9Kubernetes API\u670d\u52a1\u5668\u7684\u8bbf\u95ee\uff0c\u5b83\u7531\u4f7f\u7528kubectl\u548c\u5176\u4ed6Kubernetes\u7ec4\u4ef6\u6765\u627e\u5230\u5408\u9002\u7684API\u670d\u52a1\u5668\u5e76\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n<p>1\u3001\u83b7\u53d6kubeconfig\u6587\u4ef6<\/p>\n<p>\u767b\u5f55\u5230Vultr\u8d26\u6237\uff0c\u8fdb\u5165\u7ba1\u7406\u540e\u53f0\uff0c\u5bfc\u822a\u81f3Products &gt; Kubernetes &gt; {Your cluster} &gt; Overview\uff0c\u5355\u51fb\u4eea\u8868\u76d8\u53f3\u4e0a\u65b9\u7684Download Configuration\u6309\u94ae\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p>\n\t<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-4513\" alt=\"\u83b7\u53d6kubeconfig\u6587\u4ef6\" src=\"https:\/\/km94.com\/wp-content\/uploads\/2023\/02\/git2.jpg\"><\/figure>\n\t<\/p>\n<p>2\u3001\u8fd0\u884c\u4e0b\u9762\u547d\u4ee4\u8bbf\u95eeVultr Kubernetes Engine\u96c6\u7fa4<\/p>\n<pre class=\"wp-block-code\"><code class=\"hljs text\"><span class=\"hljs-selector-tag\">$ kubectl &#8211;kubeconfig={PATH TO THE VKE CLUSTER CONFIG FILE} get nodes<\/code><\/pre>\n<p>3\u3001\u4f7f\u7528kubectl\u521b\u5efa\u4e00\u4e2a\u540d\u4e3agitlab-runner\u7684\u540d\u79f0\u7a7a\u95f4<\/p>\n<pre class=\"wp-block-code\"><code class=\"hljs text\"><span class=\"hljs-selector-tag\">$ kubectl &#8211;kubeconfig={PATH TO THE VKE CLUSTER CONFIG FILE} create namespace gitlab<\/code><\/pre>\n<p>\u540d\u79f0\u7a7a\u95f4\u7528\u4e8e\u9694\u79bb\u5355\u4e2aKubernetes\u96c6\u7fa4\u4e2d\u7684\u8d44\u6e90\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u540d\u79f0\u7a7a\u95f4\u5c06\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\u5230\u540c\u4e00\u4e2a\u96c6\u7fa4\uff0c\u800c\u4e0d\u4f1a\u76f8\u4e92\u5e72\u6270\u3002\u8fd9\u6709\u52a9\u4e8e\u7ef4\u62a4\u548c\u672a\u6765\u5347\u7ea7\u3002<\/p>\n<p>4\u3001\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u83b7\u53d6GitLab Runner\u526f\u672c<\/p>\n<pre class=\"wp-block-code\"><code class=\"hljs text\"><span class=\"hljs-selector-tag\">git clone https:\/\/gitlab.com\/gitlab-org\/charts\/gitlab-runner.git<\/code><\/pre>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fSSH\u5bc6\u94a5\uff0c\u5219\u4e5f\u53ef\u8fd0\u884c\u4e0b\u9762\u547d\u4ee4\uff1a<\/p>\n<pre class=\"wp-block-code\"><code class=\"hljs text\"><span class=\"hljs-selector-tag\">git clone git@gitlab.com:gitlab-org\/charts\/gitlab-runner.git<\/code><\/pre>\n<p>5\u3001\u5bfc\u822a\u5230GitLab Runner\u526f\u672c\u7684\u5b58\u50a8\u5e93\uff0c\u67e5\u770bvalues.yaml\u6587\u4ef6\u3002<\/p>\n<p>## GitLab Runner Image<\/p>\n<p>image: registry.gitlab.com\/gitlab-org\/gitlab-runner:alpine-v15.3.0<\/p>\n<p>## Specify a imagePullPolicy for the main runner deployment<\/p>\n<p>imagePullPolicy: IfNotPresent<\/p>\n<p>## Timeout, in seconds, for liveness and readiness probes of a runner pod.<\/p>\n<p>probeTimeoutSeconds: 300<\/p>\n<p>## The GitLab Server URL (with protocol) that want to register the runner against<\/p>\n<p>##<\/p>\n<p>gitlabUrl: http:\/\/gitlab.com\/<\/p>\n<p>## The Registration Token for adding new Runners to the GitLab Server.<\/p>\n<p>##<\/p>\n<p>runnerRegistrationToken: &#8220;Token&#8221;<\/p>\n<p>## For RBAC support:<\/p>\n<p>rbac:<\/p>\n<p>create: true<\/p>\n<p>##<\/p>\n<p>rules:<\/p>\n<p>&#8211; resources: [&#8220;configmaps&#8221;, &#8220;pods&#8221;, &#8220;pods\/attach&#8221;, &#8220;secrets&#8221;, &#8220;services&#8221;]<\/p>\n<p>verbs: [&#8220;get&#8221;, &#8220;list&#8221;, &#8220;watch&#8221;, &#8220;create&#8221;, &#8220;patch&#8221;, &#8220;update&#8221;, &#8220;delete&#8221;]<\/p>\n<p>&#8211; apiGroups: [&#8220;&#8221;]<\/p>\n<p>resources: [&#8220;pods\/exec&#8221;]<\/p>\n<p>verbs: [&#8220;create&#8221;, &#8220;patch&#8221;, &#8220;delete&#8221;]<\/p>\n<p>## Configuration for the Pods that the runner launches for each new job<\/p>\n<p>##<\/p>\n<p>runners:<\/p>\n<p>config: |<\/p>\n<p>[[runners]]<\/p>\n<p>[runners.kubernetes]<\/p>\n<p>namespace = &#8220;{{.Release.Namespace}}&#8221;<\/p>\n<p>image = &#8220;ubuntu:16.04&#8221;<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u64cd\u4f5c\u5931\u8d25\uff0c\u8fd8\u9700\u914d\u7f6etemplates\\deployment.yaml\u6587\u4ef6\uff1a<\/p>\n<p>livenessProbe:<\/p>\n<p>&#8230;<\/p>\n<p>initialDelaySeconds: 300<\/p>\n<p>&#8230;<\/p>\n<p>readinessProbe:<\/p>\n<p>&#8230;<\/p>\n<p>initialDelaySeconds: 300<\/p>\n<p>&#8230;<\/p>\n<p>6\u3001\u914d\u7f6e\u597dGitLab Runner\u526f\u672c\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u90e8\u7f72runner\u3002<\/p>\n<pre class=\"wp-block-code\"><code class=\"hljs text\"><span class=\"hljs-selector-tag\">elm &#8211;kubeconfig={PATH_TO_VKE_CLUSTER_CONFIG FILE} install &#8211;namespace &lt;NAMESPACE&gt; gitlab-runner -f &lt;PATH_TO_CONFIG_VALUES_FILE&gt; gitlab\/gitlab-runner<\/code><\/pre>\n<p>7\u3001\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u68c0\u67e5pod\u6216\u90e8\u7f72\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"wp-block-code\"><code class=\"hljs text\"><span class=\"hljs-selector-tag\">kubectl &#8211;kubeconfig={PATH_TO_VKE_CLUSTER_CONFIG FILE} describe pods gitlab-runner &#8211;namespace=&lt;NAMESPACE&gt;<\/code><\/pre>\n<p>8\u3001\u8981\u68c0\u67e5pod\u662f\u5426\u5df2\u7ecf\u542f\u52a8\uff0c\u8bf7\u5728\u6ce8\u518c\u7684GitLab runners\u4e0b\u8fdb\u5165GitLab\uff0c\u5c06\u4f1a\u5f97\u5230\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u7ed3\u679c\u3002<\/p>\n<p>\n\t<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-4514\" alt=\"\u68c0\u67e5pod\u72b6\u6001\" src=\"https:\/\/km94.com\/wp-content\/uploads\/2023\/02\/f3.jpg\"><\/figure>\n\t<\/p>\n\n<div>\n<div>\n\n\n\n<\/div>\n<div>\n\n\n\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>GitLab Runner\u662f\u4e00\u4e2a\u5f00\u6e90\u8f6f\u4ef6\u7cfb\u7edf\uff0c\u8fd0\u884cCI\/CD\u4f5c\u4e1a\uff0c\u5e76\u5c06\u7ed3\u679c\u53d1\u9001\u5230GitLab\u3002GitLab\u4e2d\u7684&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4511,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,2],"tags":[],"class_list":["post-4510","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-zjjc","category-jc","entry"],"_links":{"self":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/posts\/4510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/comments?post=4510"}],"version-history":[{"count":0,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/posts\/4510\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/media?parent=4510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/categories?post=4510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dy208.cn\/index.php\/wp-json\/wp\/v2\/tags?post=4510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}