{"id":364165,"date":"2024-05-21T02:11:29","date_gmt":"2024-05-21T02:11:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364165"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364165","title":{"rendered":"<span>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0432 Kubernetes \u0447\u0435\u0440\u0435\u0437 Gitlab&#8217;\u043e\u0432\u0441\u043a\u0438\u0435 JWT \u0442\u043e\u043a\u0435\u043d\u044b<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/94a\/5e2\/0a8\/94a5e20a8ee713626211f275b8c0c25b.jpg\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/94a\/5e2\/0a8\/94a5e20a8ee713626211f275b8c0c25b.jpg\" data-blurred=\"true\"\/><\/figure>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<h3>\u0417\u0430\u0447\u0435\u043c?<\/h3>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043f\u043b\u043e\u0438\u043c \u043f\u043e push-\u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u043f\u043b\u043e\u044f \u0443 \u043d\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Gitlab: \u0432 \u043d\u0451\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0438 \u0434\u0436\u043e\u0431\u044b, \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0432 Kubernetes<\/p>\n<p>\u041a\u0430\u043a\u043e\u0439 \u0431\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 (kubectl, helm), \u0434\u043b\u044f \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 API \u043d\u0430\u043c \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a Kubernetes. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0431\u0443\u0434\u044c \u0442\u043e \u0442\u043e\u043a\u0435\u043d \u0438\u043b\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442. \u0418 \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<ol>\n<li>\n<p><strong>\u0413\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u043a\u0440\u0435\u0434\u044b?<\/strong><\/p>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0440\u0435\u0434\u044b \u043e\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Gitlab CI\/CD Variables \u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0434\u0436\u043e\u0431\u0443 \u0434\u0435\u043f\u043b\u043e\u044f, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0441 \u043e\u0434\u043d\u0438\u043c\u0438 \u0438 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u044b\u043b\u0438 \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440?<\/strong><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u0436\u043e\u0431\u044b \u0434\u0435\u043f\u043b\u043e\u044f \u0438 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u0443\u0434\u043e\u0431\u0435\u043d \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u043c<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f Kubernetes \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u043b \u0441\u0430\u043c Gitlab? \u0422\u043e\u0433\u0434\u0430 \u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0438\u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0440\u0435\u0434\u044b, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0431\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0443\u0431\u0435\u0440\u0435 \u043f\u043e\u0434 \u0441\u0432\u043e\u0435\u0439 \u0443\u0447\u0451\u0442\u043a\u043e\u0439 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0434\u0435\u043f\u043b\u043e\u044f<\/p>\n<h3>\u0417\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c. Gitlab ID Tokens<\/h3>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 Gitlab 15.7 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 \u0434\u0436\u043e\u0431\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/secrets\/id_token_authentication.html#id-tokens\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0435 JWT \u0442\u043e\u043a\u0435\u043d\u044b<\/a>, \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0435 \u043d\u0430 \u0438\u043c\u044f \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0434\u0436\u043e\u0431\u0443<\/p>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u0434\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0438 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u0435 <code>aud<\/code> (audience) \u0438\u043c\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u0430 (\u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u043e\u043a\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f)<\/p>\n<pre><code class=\"yaml\">job_with_id_tokens-job:   id_tokens:     MY_JWT_TOKEN:       aud: https:\/\/vault.example.com   script:     - echo $($MY_JWT_TOKEN | base64 -w0) <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430<\/p>\n<pre><code class=\"json\">{   \"namespace_id\": \"72\",   \"namespace_path\": \"my-group\",   \"project_id\": \"20\",   \"project_path\": \"my-group\/my-project\",   \"user_id\": \"1\",   \"user_login\": \"sample-user\",   \"user_email\": \"sample-user@example.com\",   \"user_identities\": [       {\"provider\": \"github\", \"extern_uid\": \"2435223452345\"},       {\"provider\": \"bitbucket\", \"extern_uid\": \"john.smith\"},   ],   \"pipeline_id\": \"574\",   \"pipeline_source\": \"push\",   \"job_id\": \"302\",   \"ref\": \"feature-branch-1\",   \"ref_type\": \"branch\",   \"ref_path\": \"refs\/heads\/feature-branch-1\",   \"ref_protected\": \"false\",   \"environment\": \"test-environment2\",   \"environment_protected\": \"false\",   \"deployment_tier\": \"testing\",   \"environment_action\": \"start\",   \"runner_id\": 1,   \"runner_environment\": \"self-hosted\",   \"sha\": \"714a629c0b401fdce83e847fc9589983fc6f46bc\",   \"project_visibility\": \"public\",   \"ci_config_ref_uri\": \"gitlab.example.com\/my-group\/my-project\/\/.gitlab-ci.yml@refs\/heads\/main\",   \"ci_config_sha\": \"714a629c0b401fdce83e847fc9589983fc6f46bc\",   \"jti\": \"235b3a54-b797-45c7-ae9a-f72d7bc6ef5b\",   \"iss\": \"https:\/\/gitlab.example.com\",   \"iat\": 1681395193,   \"nbf\": 1681395188,   \"exp\": 1681398793,   \"sub\": \"project_path:my-group\/my-project:ref_type:branch:ref:feature-branch-1\",   \"aud\": \"https:\/\/vault.example.com\" } <\/code><\/pre>\n<p>\u0421\u0430\u043c \u0442\u043e\u043a\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0439, \u043d\u043e \u043d\u0430\u0441 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u043b\u0435 <code>user_email<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 email<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Kubernetes?<\/p>\n<h3>\u0414\u043e\u0441\u0442\u0443\u043f \u0432 Kubernetes \u0447\u0435\u0440\u0435\u0437 OIDC \u0442\u043e\u043a\u0435\u043d\u044b<\/h3>\n<p><a href=\"https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/authentication\/#openid-connect-tokens\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f k8s<\/a> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0443\u0431\u043e\u0432\u044b\u0439 API Server \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 JWT \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0433\u0440\u0443\u043f\u043f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0442\u0447\u0438\u0442\u044c \u0438\u0445 \u0441 subjects, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 RBAC, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e, \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0443 kube-api-server <a href=\"https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/authentication\/#using-flags\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0443\u043a\u0430\u0436\u0435\u043c<\/p>\n<ul>\n<li>\n<p>URL \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b (\u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438)<\/p>\n<\/li>\n<li>\n<p>ID \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u043c \u0442\u043e\u043a\u0435\u043d\u0430 (\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>aud<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044f (claim) \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0433\u0440\u0443\u043f\u043f<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u0438\u043f\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u0434\u043b\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438) \u0438 CA \u0444\u0430\u0439\u043b\u0430 self-hosted \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 Gitlab<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0436\u0435, \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/p>\n<h2>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0432 Kubernetes \u0447\u0435\u0440\u0435\u0437 Gitlab&#8217;\u043e\u0432\u0441\u043a\u0438\u0435 JWT \u0442\u043e\u043a\u0435\u043d\u044b<\/h2>\n<p>\u0427\u0438\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"http:\/\/Gitlab.com\" rel=\"noopener noreferrer nofollow\">Gitlab.com<\/a> \u0438 \u0435\u0433\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u0448\u0430\u0440\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u043d\u0435\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u0421\u0432\u043e\u0439 Kubernetes \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0441 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u0431\u0435\u043b\u044b\u043c IP \u0438 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0432\u0441\u0435\u043c\u0443 \u043c\u0438\u0440\u0443 6443 \u043f\u043e\u0440\u0442\u043e\u043c kube-api-server<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b:<\/p>\n<ol>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u043f\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443 JWT \u0442\u043e\u043a\u0435\u043d\u0443, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u043e\u0442 Gitlab<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u044b \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0431\u044b\u043b\u0438 \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 RBAC \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ol>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 OIDC \u043d\u0430 kube-api-server<\/h3>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. \u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c kube-api-server \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/p>\n<pre><code class=\"bash\">--oidc-issuer-url=\"https:\/\/gitlab.com\" --oidc-client-id=\"a-k8s-01\" --oidc-username-claim=\"user_email\" --oidc-username-prefix=\"oidc:\" <\/code><\/pre>\n<ul>\n<li>\n<p>\u0422\u043e\u043a\u0435\u043d\u044b \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u0442 <a href=\"https:\/\/gitlab.com\" rel=\"noopener noreferrer nofollow\">https:\/\/gitlab.com<\/a> (\u043f\u043e\u043b\u0435 <code>iss<\/code> \u0432 \u0442\u043e\u043a\u0435\u043d\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u043a\u0435\u043d\u044b \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f a-k8s-01 (\u043f\u043e\u043b\u0435 <code>aud<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0435\u0440\u0451\u043c \u0438\u0437 \u043f\u043e\u043b\u044f <code>user_email<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412 RBAC \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <code>oidc:<\/code> \u043f\u0435\u0440\u0435\u0434 \u0438\u043c\u0435\u043d\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ul>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 RBAC<\/h3>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u043e\u0439 \u0440\u043e\u043b\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 (\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u043e\u0432)<\/p>\n<pre><code class=\"yaml\">apiVersion: rbac.authorization.k8s.io\/v1 kind: ClusterRole metadata:   name: maintainer rules: - apiGroups:   - ''   resources:   - 'namespaces'   verbs:   - 'get'   - 'list' --- apiVersion: rbac.authorization.k8s.io\/v1 kind: ClusterRoleBinding metadata:   name: maintainer roleRef:   apiGroup: rbac.authorization.k8s.io   kind: ClusterRole   name: maintainer subjects: - apiGroup: rbac.authorization.k8s.io   kind: User   name: oidc:user@example.com <\/code><\/pre>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0434\u0436\u043e\u0431\u044b \u0432 Gitlab<\/h3>\n<p>\u0422\u0443\u0442 \u0442\u043e\u0436\u0435 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0434\u0438\u043c ID Token <strong>GITLAB_K8S_JWT_TOKEN<\/strong> \u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u043c (<code>aud<\/code>) <strong>a-k8s-01<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f kubectl \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043d\u0430\u0448 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 <strong>GITLAB_K8S_JWT_TOKEN<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"yaml\">stages:   - deploy  kubectl_deploy:   stage: deploy   id_tokens:     GITLAB_K8S_JWT_TOKEN:       aud: a-k8s-01   image:     name: bitnami\/kubectl:1.28     entrypoint:       - \"\"   script:     - |       cat &lt;&lt; EOF > \/tmp\/ca.pem       &lt;CA_CERTIFICATE_CONTENT>       EOF     - API_SERVER=\"&lt;api_server_url>\"     - |       kubectl config set-cluster cluster --server=\"${API_SERVER}\" --certificate-authority=\/tmp\/ca.pem       kubectl config set-credentials user --token=\"${GITLAB_K8S_JWT_TOKEN}\"       kubectl config set-context context --cluster=cluster --user=user       kubectl config use-context context     - kubectl get ns     - kubectl get svc <\/code><\/pre>\n<h3>\u0422\u0440\u0438. \u0414\u0432\u0430. \u041e\u0434\u0438\u043d. \u0417\u0430\u043f\u0443\u0441\u043a<\/h3>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/se\/6t\/y5\/se6ty5nc_n3jsv5zld0eqdzrprq.png\" data-src=\"https:\/\/habrastorage.org\/webt\/se\/6t\/y5\/se6ty5nc_n3jsv5zld0eqdzrprq.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c: \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u044b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b, \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0435\u0442, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0451 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0440\u043e\u043b\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0430\u0440\u0435\u0437\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u044b \u043f\u043e \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u0430\u043c, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0434\u0435\u043f\u043b\u043e\u0438 \u0432 \u043f\u0440\u043e\u0434 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f&#8230;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/783586\/\"> https:\/\/habr.com\/ru\/articles\/783586\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><\/figure>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<h3>\u0417\u0430\u0447\u0435\u043c?<\/h3>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043f\u043b\u043e\u0438\u043c \u043f\u043e push-\u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u0435\u043f\u043b\u043e\u044f \u0443 \u043d\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Gitlab: \u0432 \u043d\u0451\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0438 \u0434\u0436\u043e\u0431\u044b, \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0432 Kubernetes<\/p>\n<p>\u041a\u0430\u043a\u043e\u0439 \u0431\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 (kubectl, helm), \u0434\u043b\u044f \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 API \u043d\u0430\u043c \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a Kubernetes. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0431\u0443\u0434\u044c \u0442\u043e \u0442\u043e\u043a\u0435\u043d \u0438\u043b\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442. \u0418 \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<ol>\n<li>\n<p><strong>\u0413\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u043a\u0440\u0435\u0434\u044b?<\/strong><\/p>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0440\u0435\u0434\u044b \u043e\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Gitlab CI\/CD Variables \u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0434\u0436\u043e\u0431\u0443 \u0434\u0435\u043f\u043b\u043e\u044f, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0441 \u043e\u0434\u043d\u0438\u043c\u0438 \u0438 \u0442\u0435\u043c\u0438 \u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u044b\u043b\u0438 \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440?<\/strong><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u0436\u043e\u0431\u044b \u0434\u0435\u043f\u043b\u043e\u044f \u0438 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u0443\u0434\u043e\u0431\u0435\u043d \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u043c<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f Kubernetes \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u043b \u0441\u0430\u043c Gitlab? \u0422\u043e\u0433\u0434\u0430 \u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0438\u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0440\u0435\u0434\u044b, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0431\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0443\u0431\u0435\u0440\u0435 \u043f\u043e\u0434 \u0441\u0432\u043e\u0435\u0439 \u0443\u0447\u0451\u0442\u043a\u043e\u0439 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0434\u0435\u043f\u043b\u043e\u044f<\/p>\n<h3>\u0417\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c. Gitlab ID Tokens<\/h3>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 Gitlab 15.7 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 \u0434\u0436\u043e\u0431\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/secrets\/id_token_authentication.html#id-tokens\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0435 JWT \u0442\u043e\u043a\u0435\u043d\u044b<\/a>, \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0435 \u043d\u0430 \u0438\u043c\u044f \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u0434\u0436\u043e\u0431\u0443<\/p>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u0434\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0438 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u0435 <code>aud<\/code> (audience) \u0438\u043c\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u0430 (\u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u043e\u043a\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f)<\/p>\n<pre><code class=\"yaml\">job_with_id_tokens-job:   id_tokens:     MY_JWT_TOKEN:       aud: https:\/\/vault.example.com   script:     - echo $($MY_JWT_TOKEN | base64 -w0) <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430<\/p>\n<pre><code class=\"json\">{   \"namespace_id\": \"72\",   \"namespace_path\": \"my-group\",   \"project_id\": \"20\",   \"project_path\": \"my-group\/my-project\",   \"user_id\": \"1\",   \"user_login\": \"sample-user\",   \"user_email\": \"sample-user@example.com\",   \"user_identities\": [       {\"provider\": \"github\", \"extern_uid\": \"2435223452345\"},       {\"provider\": \"bitbucket\", \"extern_uid\": \"john.smith\"},   ],   \"pipeline_id\": \"574\",   \"pipeline_source\": \"push\",   \"job_id\": \"302\",   \"ref\": \"feature-branch-1\",   \"ref_type\": \"branch\",   \"ref_path\": \"refs\/heads\/feature-branch-1\",   \"ref_protected\": \"false\",   \"environment\": \"test-environment2\",   \"environment_protected\": \"false\",   \"deployment_tier\": \"testing\",   \"environment_action\": \"start\",   \"runner_id\": 1,   \"runner_environment\": \"self-hosted\",   \"sha\": \"714a629c0b401fdce83e847fc9589983fc6f46bc\",   \"project_visibility\": \"public\",   \"ci_config_ref_uri\": \"gitlab.example.com\/my-group\/my-project\/\/.gitlab-ci.yml@refs\/heads\/main\",   \"ci_config_sha\": \"714a629c0b401fdce83e847fc9589983fc6f46bc\",   \"jti\": \"235b3a54-b797-45c7-ae9a-f72d7bc6ef5b\",   \"iss\": \"https:\/\/gitlab.example.com\",   \"iat\": 1681395193,   \"nbf\": 1681395188,   \"exp\": 1681398793,   \"sub\": \"project_path:my-group\/my-project:ref_type:branch:ref:feature-branch-1\",   \"aud\": \"https:\/\/vault.example.com\" } <\/code><\/pre>\n<p>\u0421\u0430\u043c \u0442\u043e\u043a\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0439, \u043d\u043e \u043d\u0430\u0441 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u043b\u0435 <code>user_email<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 email<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Kubernetes?<\/p>\n<h3>\u0414\u043e\u0441\u0442\u0443\u043f \u0432 Kubernetes \u0447\u0435\u0440\u0435\u0437 OIDC \u0442\u043e\u043a\u0435\u043d\u044b<\/h3>\n<p><a href=\"https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/authentication\/#openid-connect-tokens\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f k8s<\/a> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0443\u0431\u043e\u0432\u044b\u0439 API Server \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 JWT \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0438 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0433\u0440\u0443\u043f\u043f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0442\u0447\u0438\u0442\u044c \u0438\u0445 \u0441 subjects, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 RBAC, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e, \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0443 kube-api-server <a href=\"https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/authentication\/#using-flags\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0443\u043a\u0430\u0436\u0435\u043c<\/p>\n<ul>\n<li>\n<p>URL \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b (\u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438)<\/p>\n<\/li>\n<li>\n<p>ID \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u043c \u0442\u043e\u043a\u0435\u043d\u0430 (\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <code>aud<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437 \u043a\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044f (claim) \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0433\u0440\u0443\u043f\u043f<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u0438\u043f\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u0434\u043b\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438) \u0438 CA \u0444\u0430\u0439\u043b\u0430 self-hosted \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 Gitlab<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e \u0436\u0435, \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/p>\n<h2>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0432 Kubernetes \u0447\u0435\u0440\u0435\u0437 Gitlab&#8217;\u043e\u0432\u0441\u043a\u0438\u0435 JWT \u0442\u043e\u043a\u0435\u043d\u044b<\/h2>\n<p>\u0427\u0438\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"http:\/\/Gitlab.com\" rel=\"noopener noreferrer nofollow\">Gitlab.com<\/a> \u0438 \u0435\u0433\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u0448\u0430\u0440\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u043d\u0435\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u0421\u0432\u043e\u0439 Kubernetes \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0441 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u0431\u0435\u043b\u044b\u043c IP \u0438 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0432\u0441\u0435\u043c\u0443 \u043c\u0438\u0440\u0443 6443 \u043f\u043e\u0440\u0442\u043e\u043c kube-api-server<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b:<\/p>\n<ol>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u043f\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c\u0443 JWT \u0442\u043e\u043a\u0435\u043d\u0443, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u043e\u0442 Gitlab<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u044b \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0431\u044b\u043b\u0438 \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 RBAC \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ol>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 OIDC \u043d\u0430 kube-api-server<\/h3>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. \u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c kube-api-server \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/p>\n<pre><code class=\"bash\">--oidc-issuer-url=\"https:\/\/gitlab.com\" --oidc-client-id=\"a-k8s-01\" --oidc-username-claim=\"user_email\" --oidc-username-prefix=\"oidc:\" <\/code><\/pre>\n<ul>\n<li>\n<p>\u0422\u043e\u043a\u0435\u043d\u044b \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u0442 <a href=\"https:\/\/gitlab.com\" rel=\"noopener noreferrer nofollow\">https:\/\/gitlab.com<\/a> (\u043f\u043e\u043b\u0435 <code>iss<\/code> \u0432 \u0442\u043e\u043a\u0435\u043d\u0435)<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u043a\u0435\u043d\u044b \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f a-k8s-01 (\u043f\u043e\u043b\u0435 <code>aud<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0435\u0440\u0451\u043c \u0438\u0437 \u043f\u043e\u043b\u044f <code>user_email<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412 RBAC \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <code>oidc:<\/code> \u043f\u0435\u0440\u0435\u0434 \u0438\u043c\u0435\u043d\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ul>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 RBAC<\/h3>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u043e\u0439 \u0440\u043e\u043b\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 (\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u043e\u0432)<\/p>\n<pre><code class=\"yaml\">apiVersion: rbac.authorization.k8s.io\/v1 kind: ClusterRole metadata:   name: maintainer rules: - apiGroups:   - ''   resources:   - 'namespaces'   verbs:   - 'get'   - 'list' --- apiVersion: rbac.authorization.k8s.io\/v1 kind: ClusterRoleBinding metadata:   name: maintainer roleRef:   apiGroup: rbac.authorization.k8s.io   kind: ClusterRole   name: maintainer subjects: - apiGroup: rbac.authorization.k8s.io   kind: User   name: oidc:user@example.com <\/code><\/pre>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0434\u0436\u043e\u0431\u044b \u0432 Gitlab<\/h3>\n<p>\u0422\u0443\u0442 \u0442\u043e\u0436\u0435 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0434\u0438\u043c ID Token <strong>GITLAB_K8S_JWT_TOKEN<\/strong> \u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u043c (<code>aud<\/code>) <strong>a-k8s-01<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f kubectl \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043d\u0430\u0448 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 <strong>GITLAB_K8S_JWT_TOKEN<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"yaml\">stages:   - deploy  kubectl_deploy:   stage: deploy   id_tokens:     GITLAB_K8S_JWT_TOKEN:       aud: a-k8s-01   image:     name: bitnami\/kubectl:1.28     entrypoint:       - \"\"   script:     - |       cat &lt;&lt; EOF > \/tmp\/ca.pem       &lt;CA_CERTIFICATE_CONTENT>       EOF     - API_SERVER=\"&lt;api_server_url>\"     - |       kubectl config set-cluster cluster --server=\"${API_SERVER}\" --certificate-authority=\/tmp\/ca.pem       kubectl config set-credentials user --token=\"${GITLAB_K8S_JWT_TOKEN}\"       kubectl config set-context context --cluster=cluster --user=user       kubectl config use-context context     - kubectl get ns     - kubectl get svc <\/code><\/pre>\n<h3>\u0422\u0440\u0438. \u0414\u0432\u0430. \u041e\u0434\u0438\u043d. \u0417\u0430\u043f\u0443\u0441\u043a<\/h3>\n<figure class=\"\"><\/figure>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c: \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u044b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b, \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0435\u0442, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0451 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0440\u043e\u043b\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0430\u0440\u0435\u0437\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u044b \u043f\u043e \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u0430\u043c, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0434\u0435\u043f\u043b\u043e\u0438 \u0432 \u043f\u0440\u043e\u0434 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f&#8230;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/783586\/\"> https:\/\/habr.com\/ru\/articles\/783586\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-364165","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364165"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364165\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}