├── .dockerignore ├── .gcloudignore ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── documentation.md │ ├── feature_request.md │ └── question.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .rspec ├── CHANGELOG.md ├── Dockerfile ├── Dockerfile.alpine ├── Gemfile ├── Guardfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── docker └── install │ ├── docker.sh │ ├── gcloud.sh │ └── kubectl.sh ├── docs ├── .gitignore ├── CNAME ├── Gemfile ├── LICENSE ├── Procfile ├── README.md ├── Rakefile ├── _config.yml ├── _docs │ ├── ci │ │ └── cloudbuild.md │ ├── config.md │ ├── config │ │ ├── app-overrides.md │ │ ├── args.md │ │ ├── args │ │ │ ├── docker.md │ │ │ └── kubectl.md │ │ ├── boot.md │ │ ├── builder.md │ │ ├── docker.md │ │ ├── env.md │ │ ├── hooks.md │ │ ├── hooks │ │ │ ├── docker.md │ │ │ ├── generator.md │ │ │ ├── kubectl.md │ │ │ ├── kubes.md │ │ │ └── ruby.md │ │ ├── kubectl.md │ │ ├── reference.md │ │ └── skip.md │ ├── contributing.md │ ├── dsl.md │ ├── dsl │ │ ├── multiple-resources.md │ │ ├── resources.md │ │ └── resources │ │ │ ├── backend_config.md │ │ │ ├── config_map.md │ │ │ ├── daemon_set.md │ │ │ ├── deployment.md │ │ │ ├── generic.md │ │ │ ├── ingress.md │ │ │ ├── job.md │ │ │ ├── managed_certificate.md │ │ │ ├── namespace.md │ │ │ ├── network_policy.md │ │ │ ├── pod.md │ │ │ ├── role.md │ │ │ ├── role_binding.md │ │ │ ├── secret.md │ │ │ ├── service.md │ │ │ └── service_account.md │ ├── extra-env.md │ ├── extra-env │ │ ├── dsl.md │ │ └── yaml.md │ ├── generators.md │ ├── helpers.md │ ├── helpers │ │ ├── aws.md │ │ ├── aws │ │ │ ├── advanced.md │ │ │ ├── advanced │ │ │ │ ├── secrets.md │ │ │ │ └── ssm.md │ │ │ ├── iam-role.md │ │ │ ├── secret_data.md │ │ │ ├── secrets.md │ │ │ └── ssm.md │ │ ├── builtin.md │ │ ├── builtin │ │ │ └── config-map-files.md │ │ ├── custom.md │ │ ├── google.md │ │ └── google │ │ │ ├── advanced.md │ │ │ ├── advanced │ │ │ └── secrets.md │ │ │ ├── gke.md │ │ │ ├── secret_data.md │ │ │ ├── secrets.md │ │ │ └── service-account.md │ ├── install.md │ ├── install │ │ ├── dependencies.md │ │ ├── gem.md │ │ ├── gem │ │ │ └── custom-version.md │ │ ├── standalone.md │ │ └── standalone │ │ │ ├── centos.md │ │ │ ├── details.md │ │ │ ├── details │ │ │ ├── permissions.md │ │ │ └── uninstall.md │ │ │ ├── macosx.md │ │ │ └── ubuntu.md │ ├── intro.md │ ├── intro │ │ ├── concepts.md │ │ ├── docker-image.md │ │ ├── how-kubes-works.md │ │ ├── ordering.md │ │ ├── ordering │ │ │ └── custom.md │ │ └── structure.md │ ├── layering.md │ ├── layering │ │ ├── debug.md │ │ ├── dsl.md │ │ ├── extra.md │ │ ├── merge-dsl.md │ │ ├── merge-options.md │ │ ├── mix.md │ │ └── yaml.md │ ├── learn │ │ ├── dsl.md │ │ ├── dsl │ │ │ ├── change.md │ │ │ ├── cluster.md │ │ │ ├── delete.md │ │ │ ├── deploy.md │ │ │ ├── install.md │ │ │ ├── new-project.md │ │ │ ├── next-steps.md │ │ │ ├── review-project.md │ │ │ └── update.md │ │ ├── yaml.md │ │ └── yaml │ │ │ ├── change.md │ │ │ ├── cluster.md │ │ │ ├── delete.md │ │ │ ├── deploy.md │ │ │ ├── install.md │ │ │ ├── new-project.md │ │ │ ├── next-steps.md │ │ │ ├── review-project.md │ │ │ └── update.md │ ├── misc │ │ ├── auto-context.md │ │ ├── kustomize.md │ │ └── separate-steps.md │ ├── next-steps.md │ ├── patterns.md │ ├── patterns │ │ ├── central-deployer.md │ │ ├── clock-web-worker.md │ │ ├── migrations.md │ │ ├── multiple-envs.md │ │ └── secrets.md │ ├── plugins.md │ ├── plugins │ │ ├── aws.md │ │ └── google.md │ ├── resources.md │ ├── resources │ │ ├── base.md │ │ ├── role.md │ │ └── shared.md │ ├── variables.md │ ├── variables │ │ ├── advanced.md │ │ └── basic.md │ ├── vs.md │ ├── vs │ │ ├── custom.md │ │ ├── helm.md │ │ └── kustomize.md │ ├── yaml.md │ └── yaml │ │ ├── erb-comment.md │ │ ├── multiple-files.md │ │ └── multiple-resources.md ├── _includes │ ├── banner │ │ ├── foot.html │ │ └── head.html │ ├── commands.html │ ├── config │ │ ├── app-overrides-cheatsheet.md │ │ └── hooks │ │ │ ├── generator.md │ │ │ └── options.md │ ├── content.html │ ├── dsl │ │ ├── methods.md │ │ ├── rolling_deployment.md │ │ └── suffix_hash.md │ ├── example.html │ ├── footer.html │ ├── google_analytics.html │ ├── header.html │ ├── helpers │ │ ├── base64.md │ │ └── generator.md │ ├── install │ │ ├── gem.md │ │ └── wrapper.md │ ├── intro │ │ └── features.md │ ├── js.html │ ├── kubes-steps.md │ ├── layering │ │ └── layers.md │ ├── learn │ │ ├── cluster.md │ │ ├── next-steps.md │ │ ├── repo │ │ ├── repos.md │ │ ├── review.md │ │ └── start.md │ ├── plugins │ │ └── gke-config.md │ ├── reference.md │ ├── sidebar.html │ ├── variables │ │ └── generator.md │ ├── videos │ │ ├── learn.md │ │ ├── learn │ │ │ └── vs.md │ │ └── youtube.md │ └── vs │ │ ├── article.md │ │ └── kubes │ │ ├── layering.md │ │ └── structure.md ├── _layouts │ └── default.html ├── _reference │ ├── kubes-apply.md │ ├── kubes-clean.md │ ├── kubes-compile.md │ ├── kubes-completion.md │ ├── kubes-completion_script.md │ ├── kubes-delete.md │ ├── kubes-deploy.md │ ├── kubes-describe.md │ ├── kubes-docker-build.md │ ├── kubes-docker-help.md │ ├── kubes-docker-push.md │ ├── kubes-docker.md │ ├── kubes-exec.md │ ├── kubes-get.md │ ├── kubes-init.md │ ├── kubes-logs.md │ ├── kubes-new-help.md │ ├── kubes-new-helper.md │ ├── kubes-new-hook.md │ ├── kubes-new-resource.md │ ├── kubes-new-variable.md │ ├── kubes-new.md │ ├── kubes-prune.md │ └── kubes-version.md ├── _sass │ ├── bootstrap-overrides.scss │ ├── buttons.scss │ ├── caret.scss │ ├── content.scss │ ├── cta.scss │ ├── default.scss │ ├── footer.scss │ ├── masthead.scss │ ├── mixins.scss │ ├── sidebar.scss │ ├── syntax.scss │ ├── table.scss │ ├── theme.scss │ └── variables.scss ├── bin │ ├── build │ ├── rerun │ └── web ├── css │ └── main.scss ├── docs.md ├── getting-started.md ├── img │ └── logos │ │ ├── boltops-logo-full.png │ │ ├── boltops-logo.png │ │ ├── filler-logo.png │ │ ├── kubes-black.png │ │ ├── kubes-sign.png │ │ └── kubes-white.png ├── index.html ├── js │ ├── app.js │ └── scripts.js ├── opal │ ├── app.rb │ ├── pager.rb │ ├── sidebar.rb │ └── sidebar │ │ └── expander.rb ├── reference.md ├── search │ ├── data.json │ ├── index.html │ ├── lunr.js │ ├── search.js │ └── tips.md ├── support.md └── vendor │ ├── bootstrap │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── font-awesome │ ├── css │ │ ├── font-awesome.css │ │ └── font-awesome.min.css │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── less │ │ ├── animated.less │ │ ├── bordered-pulled.less │ │ ├── core.less │ │ ├── fixed-width.less │ │ ├── font-awesome.less │ │ ├── icons.less │ │ ├── larger.less │ │ ├── list.less │ │ ├── mixins.less │ │ ├── path.less │ │ ├── rotated-flipped.less │ │ ├── screen-reader.less │ │ ├── stacked.less │ │ └── variables.less │ └── scss │ │ ├── _animated.scss │ │ ├── _bordered-pulled.scss │ │ ├── _core.scss │ │ ├── _fixed-width.scss │ │ ├── _icons.scss │ │ ├── _larger.scss │ │ ├── _list.scss │ │ ├── _mixins.scss │ │ ├── _path.scss │ │ ├── _rotated-flipped.scss │ │ ├── _screen-reader.scss │ │ ├── _stacked.scss │ │ ├── _variables.scss │ │ └── font-awesome.scss │ ├── jquery │ ├── jquery.js │ ├── jquery.min.js │ ├── jquery.min.map │ ├── jquery.slim.js │ ├── jquery.slim.min.js │ └── jquery.slim.min.map │ └── simple-line-icons │ ├── css │ └── simple-line-icons.css │ ├── fonts │ ├── Simple-Line-Icons.eot │ ├── Simple-Line-Icons.svg │ ├── Simple-Line-Icons.ttf │ ├── Simple-Line-Icons.woff │ └── Simple-Line-Icons.woff2 │ ├── less │ └── simple-line-icons.less │ └── scss │ └── simple-line-icons.scss ├── exe └── kubes ├── kubes.gemspec ├── lib ├── kubes.rb ├── kubes │ ├── args │ │ ├── custom.rb │ │ └── dsl.rb │ ├── auth.rb │ ├── auth │ │ ├── base.rb │ │ ├── ecr.rb │ │ └── gcr.rb │ ├── autoloader.rb │ ├── aws_services.rb │ ├── booter.rb │ ├── cli.rb │ ├── cli │ │ ├── apply.rb │ │ ├── base.rb │ │ ├── build.rb │ │ ├── clean.rb │ │ ├── compile.rb │ │ ├── delete.rb │ │ ├── deploy.rb │ │ ├── describe.rb │ │ ├── docker.rb │ │ ├── exec.rb │ │ ├── get.rb │ │ ├── help.rb │ │ ├── help │ │ │ ├── completion.md │ │ │ ├── completion_script.md │ │ │ ├── deploy.md │ │ │ ├── exec.md │ │ │ └── new │ │ │ │ ├── helper.md │ │ │ │ ├── hook.md │ │ │ │ ├── resource.md │ │ │ │ └── variable.md │ │ ├── init.rb │ │ ├── logs.rb │ │ ├── new.rb │ │ ├── new │ │ │ ├── helper.rb │ │ │ ├── hook.rb │ │ │ ├── resource.rb │ │ │ └── variable.rb │ │ ├── prune.rb │ │ └── sequence.rb │ ├── command.rb │ ├── compiler.rb │ ├── compiler │ │ ├── decorator │ │ │ ├── base.rb │ │ │ ├── hashable.rb │ │ │ ├── hashable │ │ │ │ ├── field.rb │ │ │ │ └── storage.rb │ │ │ ├── post.rb │ │ │ └── pre.rb │ │ ├── dsl │ │ │ ├── core │ │ │ │ ├── base.rb │ │ │ │ ├── blocks.rb │ │ │ │ ├── fields.rb │ │ │ │ ├── files.rb │ │ │ │ ├── helpers.rb │ │ │ │ └── parser.rb │ │ │ └── syntax │ │ │ │ ├── backend_config.rb │ │ │ │ ├── cluster_role.rb │ │ │ │ ├── cluster_role_binding.rb │ │ │ │ ├── config_map.rb │ │ │ │ ├── daemon_set.rb │ │ │ │ ├── deployment.rb │ │ │ │ ├── endpoint.rb │ │ │ │ ├── ingress.rb │ │ │ │ ├── job.rb │ │ │ │ ├── managed_certificate.rb │ │ │ │ ├── namespace.rb │ │ │ │ ├── network_policy.rb │ │ │ │ ├── pod.rb │ │ │ │ ├── resource.rb │ │ │ │ ├── role.rb │ │ │ │ ├── role_binding.rb │ │ │ │ ├── secret.rb │ │ │ │ ├── service.rb │ │ │ │ └── service_account.rb │ │ ├── layering.rb │ │ ├── shared │ │ │ ├── helpers.rb │ │ │ ├── helpers │ │ │ │ ├── config_map_helper.rb │ │ │ │ ├── deprecated.rb │ │ │ │ ├── docker_helper.rb │ │ │ │ ├── extra_helper.rb │ │ │ │ └── secret_helper.rb │ │ │ └── runtime_helpers.rb │ │ ├── strategy.rb │ │ ├── strategy │ │ │ ├── base.rb │ │ │ ├── dispatcher.rb │ │ │ ├── erb.rb │ │ │ ├── erb │ │ │ │ ├── comment.rb │ │ │ │ └── yaml_error.rb │ │ │ ├── pass.rb │ │ │ └── result.rb │ │ └── util │ │ │ ├── normalize.rb │ │ │ ├── save_file.rb │ │ │ └── yaml_dump.rb │ ├── completer.rb │ ├── completer │ │ ├── script.rb │ │ └── script.sh │ ├── config.rb │ ├── core.rb │ ├── docker.rb │ ├── docker │ │ ├── args │ │ │ └── default.rb │ │ └── strategy │ │ │ ├── build │ │ │ ├── base.rb │ │ │ ├── docker.rb │ │ │ └── gcloud.rb │ │ │ ├── image_name.rb │ │ │ ├── push │ │ │ ├── base.rb │ │ │ ├── docker.rb │ │ │ └── gcloud.rb │ │ │ └── utils.rb │ ├── hooks │ │ ├── builder.rb │ │ ├── concern.rb │ │ ├── dsl.rb │ │ └── runner.rb │ ├── kubectl.rb │ ├── kubectl │ │ ├── args │ │ │ ├── base.rb │ │ │ ├── kustomize.rb │ │ │ └── standard.rb │ │ ├── batch.rb │ │ ├── dispatcher.rb │ │ ├── fetch │ │ │ ├── base.rb │ │ │ ├── deployment.rb │ │ │ └── pods.rb │ │ ├── kustomize.rb │ │ └── ordering.rb │ ├── logger.rb │ ├── logging.rb │ ├── plugin.rb │ ├── util │ │ ├── consider.rb │ │ ├── pretty.rb │ │ ├── sh.rb │ │ ├── sure.rb │ │ └── time.rb │ └── version.rb └── templates │ ├── base │ └── .kubes │ │ ├── config.rb.tt │ │ └── config │ │ └── env │ │ ├── dev.rb │ │ └── prod.rb │ ├── docker │ └── Dockerfile │ ├── dsl │ └── .kubes │ │ └── resources │ │ ├── base │ │ └── all.rb.tt │ │ ├── shared │ │ └── namespace.rb.tt │ │ └── web │ │ ├── deployment.rb │ │ ├── deployment │ │ ├── dev.rb │ │ └── prod.rb │ │ └── service.rb │ ├── new │ ├── helper │ │ └── file.rb │ ├── hooks │ │ ├── docker.rb │ │ ├── kubectl.rb │ │ └── kubes.rb │ ├── resource │ │ ├── dsl │ │ │ ├── backend_config.rb │ │ │ ├── config_map.rb │ │ │ ├── daemon_set.rb │ │ │ ├── deployment.rb │ │ │ ├── endpoint.rb │ │ │ ├── ingress.rb │ │ │ ├── job.rb │ │ │ ├── managed_certificate.rb │ │ │ ├── namespace.rb │ │ │ ├── network_policy.rb │ │ │ ├── pod.rb │ │ │ ├── role.rb │ │ │ ├── role_binding.rb │ │ │ ├── secret.rb │ │ │ ├── service.rb │ │ │ └── service_account.rb │ │ └── yaml │ │ │ ├── backend_config.yaml │ │ │ ├── config_map.yaml │ │ │ ├── daemon_set.yaml │ │ │ ├── deployment.yaml │ │ │ ├── endpoint.yaml │ │ │ ├── ingress.yaml │ │ │ ├── job.yaml │ │ │ ├── managed_certificate.yaml │ │ │ ├── namespace.yaml │ │ │ ├── network_policy.yaml │ │ │ ├── pod.yaml │ │ │ ├── role.yaml │ │ │ ├── role_binding.yaml │ │ │ ├── secret.yaml │ │ │ ├── service.yaml │ │ │ └── service_account.yaml │ └── variable │ │ └── file.rb │ └── yaml │ └── .kubes │ └── resources │ ├── base │ ├── all.yaml.tt │ └── deployment.yaml.tt │ ├── shared │ └── namespace.yaml.tt │ └── web │ ├── deployment.yaml.tt │ ├── deployment │ ├── dev.yaml │ └── prod.yaml │ └── service.yaml.tt └── spec ├── cli_spec.rb ├── fixtures ├── artifacts │ └── demo-web │ │ ├── deployment.yaml │ │ └── service.yaml ├── blocks │ └── deployments.rb ├── decorators │ ├── deployment │ │ ├── both │ │ │ ├── envFrom.yaml │ │ │ ├── valueFrom.yaml │ │ │ └── volumes.yaml │ │ ├── configMap │ │ │ ├── envFrom.yaml │ │ │ ├── valueFrom.yaml │ │ │ ├── volumes-name-first.yaml │ │ │ ├── volumes-name-second.yaml │ │ │ └── volumes.yaml │ │ └── secret │ │ │ ├── envFrom.yaml │ │ │ ├── valueFrom.yaml │ │ │ └── volumes.yaml │ ├── ingress │ │ └── tls.yaml │ └── pod │ │ ├── configMap │ │ ├── envFrom.yaml │ │ ├── valueFrom.yaml │ │ └── volumes.yaml │ │ └── secret │ │ ├── envFrom.yaml │ │ ├── valueFrom.yaml │ │ └── volumes.yaml ├── deployments │ ├── minimum.rb │ ├── props.rb │ └── setter │ │ ├── container.rb │ │ ├── containers.rb │ │ ├── metadata.rb │ │ ├── sidecar.rb │ │ └── spec.rb ├── multiple-files │ └── .kubes │ │ └── resources │ │ └── web │ │ ├── deployment-1.rb │ │ └── deployment-2.rb ├── project │ ├── .gitignore │ └── .kubes │ │ └── resources │ │ └── web │ │ ├── deployment.rb │ │ ├── empty.rb │ │ └── service.rb ├── prune │ ├── capture.yaml │ └── fetch_items.yaml ├── services │ └── minimum.rb └── syntax │ └── .kubes │ └── resources │ └── web │ ├── network_policy.rb │ └── pod.rb ├── kubes ├── cli │ └── prune_spec.rb ├── compiler │ ├── decorator │ │ └── post │ │ │ ├── deployment_spec.rb │ │ │ ├── ingress_spec.rb │ │ │ └── pod_spec.rb │ └── strategy │ │ └── dispatcher_spec.rb ├── compiler_spec.rb ├── dsl │ ├── daemon_set.rb │ ├── deployment_spec.rb │ ├── network_policy_spec.rb │ ├── pod_spec.rb │ └── service_spec.rb └── kubectl │ └── batch_spec.rb └── spec_helper.rb /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | pkg 3 | docs 4 | spec -------------------------------------------------------------------------------- /.gcloudignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.bundle 4 | /.config 5 | /.yardoc 6 | /_yardoc 7 | /coverage 8 | /doc/ 9 | /Gemfile.lock 10 | /InstalledFiles 11 | /lib/bundler/man 12 | /pkg 13 | /rdoc 14 | /spec/reports 15 | /test/tmp 16 | /test/version_tmp 17 | /tmp 18 | 19 | .git 20 | pkg 21 | docs 22 | spec 23 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: boltops-tools 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please fill out one of the templates on https://github.com/boltops-tools/kubes/issues/new/choose 2 | 3 | If you want to ask a question please do so on sites like StackOverflow. 4 | 5 | To be sensitive to everyone's time, we may close issues asking questions without comment. Here are some additional options also https://kubes.guru/support/ 👌 6 | 7 | Thank you! 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation 3 | about: Found a typo or something that isn't crystal clear in the docs? 4 | title: '' 5 | labels: docs 6 | assignees: '' 7 | 8 | --- 9 | 10 | The Kubes Docs are in the [kubes repo](https://github.com/boltops-tools/kubes/tree/master/docs). Please submit a PR there. Thanks! 11 | 12 | For documentation changes to the kubes code base itself, like code comments. Please submit a PR here. Thanks! -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Have any questions about how Kubes works? 4 | title: '' 5 | labels: 'question' 6 | assignees: '' 7 | 8 | --- 9 | 10 | The Kubes issue tracker IS NOT for usage questions! Please post your question at sites like StackOverflow. 11 | 12 | To be sensitive to everyone's time, we may close issues asking questions without comment. If you repeatedly post questions in the issues tracker, you may be blocked from ever submitting issues to Kubes again. Please use your best judgment. 👍 13 | 14 | Here are some additional options also https://kubes.guru/support/ 😁 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.bundle 4 | /.config 5 | /.yardoc 6 | /_yardoc 7 | /coverage 8 | /doc/ 9 | /Gemfile.lock 10 | /InstalledFiles 11 | /lib/bundler/man 12 | /pkg 13 | /rdoc 14 | /spec/reports 15 | /test/tmp 16 | /test/version_tmp 17 | /tmp 18 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | --color 3 | --format documentation 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.7 2 | 3 | COPY docker docker 4 | RUN docker/install/docker.sh 5 | RUN docker/install/gcloud.sh 6 | ENV PATH=/opt/google/google-cloud-sdk/bin/:$PATH 7 | RUN docker/install/kubectl.sh 8 | 9 | WORKDIR /app 10 | ADD . /app 11 | RUN bundle install 12 | RUN rake install 13 | 14 | ENTRYPOINT ["/usr/local/bundle/bin/kubes"] 15 | -------------------------------------------------------------------------------- /Dockerfile.alpine: -------------------------------------------------------------------------------- 1 | FROM ruby:2.7-alpine 2 | 3 | # This Dockerfile is much lighter but won't work with gke whitelisting. Getting this error when the google gke sdk is called: 4 | # 5 | # Error loading shared library ld-linux-x86-64.so.2: No such file or directory #986 6 | # 7 | # If you don't need gke whitelisting, then this image should work and is lighter. 8 | 9 | RUN apk add --no-cache docker 10 | RUN apk add --no-cache build-base ruby ruby-dev 11 | 12 | RUN wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/bin/linux/amd64/kubectl 13 | RUN chmod u+x kubectl && mv kubectl /bin/kubectl 14 | 15 | WORKDIR /app 16 | ADD . /app 17 | RUN bundle install 18 | RUN rake install 19 | 20 | ENTRYPOINT ["/usr/local/bundle/bin/kubes"] 21 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Specify your gem dependencies in kubes.gemspec 4 | gemspec 5 | 6 | gem "codeclimate-test-reporter", group: :test, require: nil 7 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | guard "bundler", cmd: "bundle" do 2 | watch("Gemfile") 3 | watch(/^.+\.gemspec/) 4 | end 5 | 6 | guard :rspec, cmd: "bundle exec rspec" do 7 | require "guard/rspec/dsl" 8 | dsl = Guard::RSpec::Dsl.new(self) 9 | 10 | # RSpec files 11 | rspec = dsl.rspec 12 | watch(rspec.spec_helper) { rspec.spec_dir } 13 | watch(rspec.spec_support) { rspec.spec_dir } 14 | watch(rspec.spec_files) 15 | 16 | # Ruby files 17 | ruby = dsl.ruby 18 | dsl.watch_spec_files_for(ruby.lib_files) 19 | end 20 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | task default: :spec 5 | 6 | RSpec::Core::RakeTask.new 7 | 8 | require_relative "lib/kubes" 9 | require "cli_markdown" 10 | desc "Generates cli reference docs as markdown" 11 | task :docs do 12 | mkdir_p "docs/_includes" 13 | CliMarkdown::Creator.create_all(cli_class: Kubes::CLI, cli_name: "kubes") 14 | end 15 | -------------------------------------------------------------------------------- /docker/install/docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | apt-get update 4 | apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y 5 | curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - 6 | add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" 7 | apt-get update 8 | apt-get install docker-ce docker-ce-cli containerd.io -y 9 | -------------------------------------------------------------------------------- /docker/install/gcloud.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | 3 | [ -e /opt/google ] && exit 4 | 5 | mkdir -p /opt/google 6 | 7 | cd /opt/google 8 | wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-318.0.0-linux-x86_64.tar.gz 9 | tar zxf google-cloud-sdk*.tar.gz 10 | rm -f google-cloud-sdk*.tar.gz 11 | 12 | /opt/google/google-cloud-sdk/install.sh -q 13 | 14 | cat << FOE >> ~/.bash_profile 15 | 16 | source /opt/google/google-cloud-sdk/completion.bash.inc 17 | source /opt/google/google-cloud-sdk/path.bash.inc 18 | FOE 19 | -------------------------------------------------------------------------------- /docker/install/kubectl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/bin/linux/amd64/kubectl 4 | chmod u+x kubectl && mv kubectl /bin/kubectl 5 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | .sass-cache 3 | .jekyll-metadata 4 | .jekyll-cache 5 | Gemfile.lock 6 | _config-dev.yml 7 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | kubes.guru -------------------------------------------------------------------------------- /docs/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "html-proofer" 4 | gem "jekyll" 5 | gem "jekyll-include-cache" 6 | gem "opal" 7 | gem "opal-browser" 8 | gem "opal-jquery" 9 | gem "rake" 10 | gem "rerun" 11 | gem "webrick" 12 | 13 | # GitHub pages does not support this plugin. 14 | # GitHub pages will not serve zipped assets even if we precompress them before hand. 15 | # Leaving comment as a note: 16 | # group :jekyll_plugins do 17 | # gem 'jekyll-gzip' 18 | # end -------------------------------------------------------------------------------- /docs/Procfile: -------------------------------------------------------------------------------- 1 | web: bin/web 2 | opal: bin/rerun -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # kubes Documentation 2 | 3 | This project powers the kubes documementation website: [https://kubes.guru](https://kubes.guru). It is a static website generated by [Jekyll](https://jekyllrb.com/). 4 | 5 | ## Contributing 6 | 7 | For minor changes like typos, you can click **Suggest an edit to this page**, located at the bottom of each article. This will take you to the source file on GitHub, where you can submit a pull request for your change through the UI. 8 | 9 | ## Local Setup 10 | 11 | For larger fixes, you can run the site locally with the following: 12 | 13 | git clone https://github.com/boltops-tools/kubes 14 | cd kubes/docs 15 | bundle 16 | foreman start 17 | 18 | You'll be able to view the site on [http://localhost:4000](http://localhost:4000). 19 | 20 | ## Html Proofer 21 | 22 | Run it locally once in a while. Sometimes external sites are intermittently down, even GitHub. 23 | 24 | bundle exec rake html:proof 25 | -------------------------------------------------------------------------------- /docs/Rakefile: -------------------------------------------------------------------------------- 1 | # server-side require 2 | require 'opal' 3 | require 'opal-jquery' 4 | require 'opal-browser' 5 | 6 | 7 | # Note the jekyll-opal plugin loads a minimum baseline of opal that doesnt including extra side-side requires 8 | # So we'll compile our own version instead. 9 | 10 | namespace :opal do 11 | desc "Build our app to app.js" 12 | task :build do 13 | puts "build opal files" 14 | Opal.append_path "./opal" 15 | compiled = Opal::Builder.build("app").to_s 16 | IO.write("js/app.js", compiled) 17 | end 18 | end 19 | 20 | require 'html-proofer' 21 | 22 | namespace :html do 23 | desc "proof read the html links" 24 | task :proof do 25 | system "bundle exec jekyll build" 26 | HTMLProofer.check_directory( 27 | "./_site", 28 | # hacks to get html proof to pass links we wanted ignored 29 | check_html: true, 30 | # check_favicon: true, 31 | only_4xx: true, 32 | allow_hash_href: true, 33 | empty_alt_ignore: true, 34 | ).run 35 | end 36 | end 37 | 38 | task :default => ["opal:build", "html:proof"] 39 | -------------------------------------------------------------------------------- /docs/_docs/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Config 3 | --- 4 | 5 | You can customize the behavior of Kubes with configs. There are different types of configs: 6 | 7 | * [Docker]({% link _docs/config/docker.md %}): Used to customize the docker command. 8 | * [Env]({% link _docs/config/env.md %}): Used to override `config.rb` settings on a `KUBES_ENV` basis. 9 | * [Kubectl]({% link _docs/config/env.md %}): Used to customize the kubectl command. 10 | -------------------------------------------------------------------------------- /docs/_docs/config/app-overrides.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: App Overrides Cheatsheet 3 | --- 4 | 5 | Kubes supports app-level overrides. This is especially useful for the [Central Deployer Pattern]({% link _docs/patterns/central-deployer.md %}). 6 | 7 | {% include config/app-overrides-cheatsheet.md %} 8 | -------------------------------------------------------------------------------- /docs/_docs/config/args.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Args 3 | --- 4 | 5 | Kubes supports customizing the args passed to the `docker` and `kubectl` commands: 6 | 7 | {% assign docs = site.docs | where: "categories","args" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.title }}]({{ doc.url }}) 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /docs/_docs/config/args/docker.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Docker Args 3 | nav_text: Docker 4 | categories: args 5 | --- 6 | 7 | Here are some examples of customizing the docker args. 8 | 9 | .kubes/config/args/docker.rb 10 | 11 | ```ruby 12 | command("build", 13 | args: ["--quiet"], 14 | ) 15 | 16 | command("push", 17 | args: ["--disable-content-trust"], 18 | ) 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/_docs/config/args/kubectl.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubectl Args 3 | nav_text: Kubectl 4 | categories: args 5 | --- 6 | 7 | Here are some examples of customizing the kubectl args. 8 | 9 | .kubes/config/kubectl/args.rb 10 | 11 | ```ruby 12 | command("apply", 13 | args: ["--validate=true"], 14 | ) 15 | 16 | command("delete", 17 | args: ["--grace-period=-1"], 18 | ) 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/_docs/config/docker.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Docker Config 3 | --- 4 | 5 | ## General 6 | 7 | Kubes builds docker images by calling the docker build commands. Example: 8 | 9 | kubes docker build 10 | 11 | To push: 12 | 13 | kubes docker push 14 | 15 | ## Deploy 16 | 17 | While building the docker image as a separate step can be useful, you can just use the deploy command, and kubes will automatically build the Docker image for you. Example: 18 | 19 | kubes deploy web 20 | 21 | If you want to skip the `docker build` phase of the deploy, you can run: 22 | 23 | kubes deploy web --no-build 24 | 25 | Also, kubes apply another way to skip the docker build: 26 | 27 | kubes apply web 28 | 29 | ## Customizing Args and Hooks 30 | 31 | See: 32 | 33 | * [Docker Args Docs]({% link _docs/config/args/docker.md %}) 34 | * [Docker Hooks Docs]({% link _docs/config/hooks/docker.md %}) 35 | -------------------------------------------------------------------------------- /docs/_docs/config/hooks.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hooks 3 | --- 4 | 5 | Kubes supports a variety of hooks. They can be used to customize and finely control the kubes deploy process. 6 | 7 | {% assign docs = site.docs | where: "categories","hooks" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.title }}]({{ doc.url }}) 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /docs/_docs/config/hooks/generator.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hook Generator 3 | nav_text: Generator 4 | categories: hooks 5 | order: 9 6 | --- 7 | 8 | ## Examples 9 | 10 | $ kubes new hook docker 11 | create .kubes/config/hooks/docker.rb 12 | $ kubes new hook kubectl 13 | create .kubes/config/hooks/kubectl.rb 14 | $ kubes new hook kubes 15 | create .kubes/config/hooks/kubes.rb 16 | $ -------------------------------------------------------------------------------- /docs/_docs/config/kubectl.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubectl Customizations 3 | --- 4 | 5 | ## General 6 | 7 | Kubes calls out the `kubectl` command. You can customize the command. 8 | 9 | * [Args]({% link _docs/config/args/kubectl.md %}): Customize the CLI args. 10 | * [Hooks]({% link _docs/config/hooks/kubectl.md %}): Run hooks before and after the kubectl commands. 11 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Resources 3 | --- 4 | 5 | Here's a list of the resources supported by the Kubes DSL. 6 | 7 | {% assign docs = site.docs | where: "categories","dsl" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.title }}]({{ doc.url }}) 10 | {% endfor %} 11 | 12 | For resources, that are not supported, you can use the [Generic resource]({% link _docs/dsl/resources/generic.md %}) or use [YAML]({% link _docs/yaml.md %}) instead. You can use a mix of DSL and YAML definitions in the `.kubes/resources` folder. 13 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/backend_config.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: BackendConfig 3 | categories: dsl 4 | --- 5 | 6 | A [BackendConfig](https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features#create_backendconfig) is [custom resource definitions (CRDs)](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) that allow you to further customize the load balancer. 7 | 8 | Here's an example of a BackendConfig. 9 | 10 | .kubes/resources/web/backend-config.rb 11 | 12 | ```ruby 13 | name "backendconfig" 14 | spec( 15 | timeoutSec: 40, 16 | connectionDraining: { 17 | drainingTimeoutSec: 60, 18 | }, 19 | sessionAffinity: { 20 | affinityType: "CLIENT_IP", 21 | } 22 | ) 23 | ``` 24 | 25 | Produces: 26 | 27 | .kubes/output/web/backend-config.yaml 28 | 29 | ```yaml 30 | --- 31 | apiVersion: cloud.google.com/v1 32 | kind: BackendConfig 33 | metadata: 34 | name: my-bsc-backendconfig 35 | spec: 36 | timeoutSec: 40 37 | connectionDraining: 38 | drainingTimeoutSec: 60 39 | sessionAffinity: 40 | affinityType: CLIENT_IP 41 | ``` 42 | 43 | ## DSL Methods 44 | 45 | {% include dsl/methods.md name="backend_config" %} 46 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/daemon_set.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: DaemonSet 3 | categories: dsl 4 | --- 5 | 6 | ## Example 7 | 8 | Here's an example of a DaemonSet. 9 | 10 | .kubes/resources/shared/daemon_set.rb 11 | 12 | ```ruby 13 | name "calico-node" 14 | namespace "kube-system" 15 | labels("k8s-app": "calico-node") 16 | updateStrategy( 17 | type: "RollingUpdate", 18 | rollingUpdate: { 19 | maxUnavailable: 1 20 | } 21 | ) 22 | annotations( 23 | "*scheduler**.alpha.kubernetes.io/critical-pod": '*' 24 | ) 25 | ``` 26 | 27 | Produces: 28 | 29 | .kubes/output/shared/daemon_set.yaml 30 | 31 | ```yaml 32 | apiVersion: apps/v1 33 | kind: DaemonSet 34 | metadata: 35 | annotations: 36 | "*scheduler**.alpha.kubernetes.io/critical-pod": "*" 37 | name: calico-node 38 | labels: 39 | k8s-app: calico-node 40 | namespace: kube-system 41 | spec: 42 | updateStrategy: 43 | type: RollingUpdate 44 | rollingUpdate: 45 | maxUnavailable: 1 46 | ``` 47 | 48 | ## DSL Methods 49 | 50 | Here's a list of more common methods: 51 | 52 | * minReadySeconds 53 | * revisionHistoryLimit 54 | * selector 55 | * template 56 | * updateStrategy 57 | 58 | {% include dsl/methods.md name="daemon_set" %} 59 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/generic.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Generic 3 | categories: dsl 4 | --- 5 | 6 | The generic DSL allows you to create any Kubernetes resource kind with the Kubes DSL. It is useful for resources with no pretty Kubes DSL wrappers yet. It still has some pretty powerful helper methods. 7 | 8 | ## Example 1 9 | 10 | Here's an example of an example of a make-believe SomeKind resource. 11 | 12 | .kubes/resources/web/some_kind.rb 13 | 14 | ```ruby 15 | name "some-kind" 16 | labels(role: "web") 17 | spec( 18 | spec1: "v1" 19 | ) 20 | field(:data, 21 | k1: "v1", 22 | k2: "v2" 23 | ) 24 | ``` 25 | 26 | Produces: 27 | 28 | .kubes/output/web/some_kind.yaml 29 | 30 | ```yaml 31 | data: 32 | k1: v1 33 | k2: v2 34 | kind: SomeKind 35 | metadata: 36 | name: some-kind 37 | labels: 38 | role: web 39 | spec: 40 | spec1: v1 41 | ``` 42 | 43 | ## DSL Methods 44 | 45 | Here's a list of common methods: 46 | 47 | Top-level and special fields: 48 | 49 | * apiVersion 50 | * kind 51 | * metadata 52 | * resource 53 | * spec 54 | * annotations 55 | * labels 56 | * namespace 57 | 58 | {% include dsl/methods.md name="resource" %} 59 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/job.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Job 3 | categories: dsl 4 | --- 5 | 6 | ## Example 1 7 | 8 | Here's an example of an job. 9 | 10 | .kubes/resources/migrate/job.rb 11 | 12 | ```ruby 13 | name "<%= app %>" 14 | image(docker_image) 15 | ``` 16 | 17 | Produces: 18 | 19 | .kubes/output/migrate/job.yaml 20 | 21 | ```yaml 22 | --- 23 | apiVersion: batch/v1 24 | kind: Job 25 | metadata: 26 | name: demo 27 | labels: 28 | app: demo 29 | namespace: demo-dev 30 | spec: 31 | template: 32 | metadata: 33 | labels: 34 | app: demo 35 | spec: 36 | containers: 37 | - image: 111111111111.dkr.ecr.us-west-2.amazonaws.com/demo:kubes-2020-10-26T20-25-43 38 | name: demo 39 | ``` 40 | 41 | ## DSL Methods 42 | 43 | Here's a list of more common methods: 44 | 45 | job.spec.template.spec.containers fields: 46 | 47 | * args 48 | * command 49 | * env 50 | * envFrom 51 | * image 52 | * imagePullPolicy 53 | * lifecycle 54 | * livenessProbe 55 | * containerName 56 | * ports 57 | * readinessProbe 58 | * volumeDevices 59 | * volumeMounts 60 | * workingDir 61 | 62 | {% include dsl/methods.md name="job" %} 63 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/managed_certificate.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ManagedCertificate 3 | categories: dsl 4 | --- 5 | 6 | Here's an example of a ManagedCertificate. 7 | 8 | .kubes/resources/web/managed_certificate.rb 9 | 10 | ```ruby 11 | name "cert1" 12 | domains(["cert1.example.com"]) 13 | ``` 14 | 15 | Produces: 16 | 17 | .kubes/output/web/managed_certificate.yaml 18 | 19 | ```yaml 20 | --- 21 | apiVersion: networking.gke.io/v1beta2 22 | kind: ManagedCertificate 23 | metadata: 24 | name: cert1 25 | spec: 26 | domains: 27 | - cert1.example.com 28 | ``` 29 | 30 | ## DSL Methods 31 | 32 | Here's a list of more common methods: 33 | 34 | Top-level and special fields: 35 | 36 | * domain 37 | * domains 38 | 39 | {% include dsl/methods.md name="managed_certificate" %} 40 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/namespace.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Namespace 3 | categories: dsl 4 | --- 5 | 6 | ## Example 7 | 8 | Here's an example of a Namespace. 9 | 10 | .kubes/resources/shared/namespace.rb 11 | 12 | ```ruby 13 | name "demo" 14 | labels(app: "demo") # useful with NetworkPolicy 15 | ``` 16 | 17 | Produces: 18 | 19 | .kubes/output/shared/namespace.yaml 20 | 21 | ```yaml 22 | apiVersion: v1 23 | kind: Namespace 24 | metadata: 25 | name: demo 26 | labels: 27 | app: demo 28 | ``` 29 | 30 | ## DSL Methods 31 | 32 | Here's the source of the namespace resource. 33 | 34 | {% include dsl/methods.md name="namespace" %} 35 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/role.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Role 3 | categories: dsl 4 | --- 5 | 6 | ## Example 7 | 8 | Here's an example of a Role. 9 | 10 | .kubes/resources/shared/role.rb 11 | 12 | ```ruby 13 | name "demo" 14 | apiGroups([""]) 15 | resources(["pods"]) 16 | verbs(["get", "watch", "list"]) 17 | ``` 18 | 19 | Produces: 20 | 21 | .kubes/output/shared/role.yaml 22 | 23 | ```yaml 24 | apiVersion: rbac.authorization.k8s.io/v1 25 | kind: Role 26 | metadata: 27 | name: demo 28 | rules: 29 | - apiGroups: 30 | - '' 31 | resources: 32 | - pods 33 | verbs: 34 | - get 35 | - watch 36 | - list 37 | ``` 38 | 39 | ## DSL Methods 40 | 41 | Here's the source of the Role resource. 42 | 43 | {% include dsl/methods.md name="role" %} 44 | 45 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/role_binding.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: RoleBinding 3 | categories: dsl 4 | --- 5 | 6 | ## Example 7 | 8 | Here's an example of a RoleBinding. 9 | 10 | .kubes/resources/shared/role_binding.rb 11 | 12 | ```ruby 13 | name "demo" 14 | 15 | subjects([ 16 | {kind: "User", name: "tung@boltops.com"}, 17 | ]) 18 | 19 | roleName "demo" 20 | ``` 21 | 22 | Produces: 23 | 24 | .kubes/output/shared/role_binding.yaml 25 | 26 | ```yaml 27 | apiVersion: rbac.authorization.k8s.io/v1 28 | kind: RoleBinding 29 | metadata: 30 | name: demo 31 | roleRef: 32 | apiGroup: rbac.authorization.k8s.io 33 | kind: Role 34 | name: demo 35 | subjects: 36 | - kind: User 37 | name: tung@boltops.com 38 | ``` 39 | 40 | ## DSL Methods 41 | 42 | Here's a list of more common methods: 43 | 44 | Top-level methods: 45 | 46 | * roleRef 47 | * subjects 48 | 49 | roleRef level methods 50 | 51 | * apiGroup 52 | * roleKind 53 | * roleName 54 | 55 | {% include dsl/methods.md name="role_binding" %} 56 | -------------------------------------------------------------------------------- /docs/_docs/dsl/resources/service_account.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ServiceAccount 3 | categories: dsl 4 | --- 5 | 6 | ## Example 7 | 8 | Here's an example of a ServiceAccount. 9 | 10 | .kubes/resources/shared/service_account.rb 11 | 12 | ```ruby 13 | name "demo" 14 | ``` 15 | 16 | Produces: 17 | 18 | .kubes/output/shared/service_account.yaml 19 | 20 | ```yaml 21 | apiVersion: v1 22 | kind: ServiceAccount 23 | metadata: 24 | name: demo 25 | ``` 26 | 27 | ## DSL Methods 28 | 29 | Here's a list of more common methods: 30 | 31 | Top-level methods: 32 | 33 | * automountServiceAccountToken 34 | * imagePullSecrets 35 | * secrets 36 | 37 | {% include dsl/methods.md name="service_account" %} 38 | -------------------------------------------------------------------------------- /docs/_docs/extra-env.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Extra Environments 3 | --- 4 | 5 | Kubes adds the concept of extra environments. Let say, you have a demo-web app with a deployment and service. 6 | 7 | .kubes/resources 8 | └── web 9 | ├── deployment.rb 10 | └── service.rb 11 | 12 | You can create additional environments using the same resource files with a few minor changes. 13 | 14 | * [DSL Example]({% link _docs/extra-env/dsl.md %}) 15 | * [YAML Example]({% link _docs/extra-env/yaml.md %}) 16 | 17 | ## Deploy 18 | 19 | Then to create an additional environment, it's simple: 20 | 21 | KUBES_EXTRA=2 kubes deploy 22 | KUBES_EXTRA=3 kubes deploy 23 | # etc 24 | -------------------------------------------------------------------------------- /docs/_docs/generators.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Generators 3 | --- 4 | 5 | Kubes ships with a few generators to help you get building with Kubernetes quickly. The generated starter YAML should be modified and customized for your needs. 6 | 7 | ## Examples 8 | 9 | Here are a few examples: 10 | 11 | $ kubes new resource ingress 12 | create .kubes/resources/web/ingress.yaml 13 | $ kubes new resource service_account 14 | create .kubes/resources/shared/service_account.yaml 15 | $ 16 | 17 | Use `-h` to see the cli options: 18 | 19 | kubes new resource -h 20 | 21 | ## Supported Resources 22 | 23 | Here's a list of some of the supported resources. 24 | 25 | backend_config 26 | config_map 27 | daemon_set 28 | deployment 29 | ingress 30 | job 31 | managed_certificate 32 | namespace 33 | network_policy 34 | pod 35 | role_binding 36 | role 37 | secret 38 | service_account 39 | service 40 | 41 | Refer to the [source code](https://github.com/boltops-tools/kubes/blob/master/lib/templates/new/resource/yaml) to all the resources that the generator supports. 42 | -------------------------------------------------------------------------------- /docs/_docs/helpers.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Helpers 3 | --- 4 | 5 | ## Built-In Helpers 6 | 7 | Kubes provides core helper methods to help write Kubernetes YAML files. Docs: [Built-In Helpers]({% link _docs/helpers/builtin.md %}). 8 | 9 | ## DSL Specific Methods 10 | 11 | Each DSL resource has it's own specific methods. Refer to the [DSL Docs]({% link _docs/dsl.md %}) for their methods. 12 | 13 | ## Provider Helpers 14 | 15 | There are also provider-specific helpers: 16 | 17 | * [AWS Helpers]({% link _docs/helpers/aws.md %}) 18 | * [Google Helpers]({% link _docs/helpers/google.md %}) 19 | 20 | {% include helpers/generator.md %} -------------------------------------------------------------------------------- /docs/_docs/helpers/aws.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: AWS Helpers 3 | --- 4 | 5 | List of AWS helpers: 6 | 7 | {% assign docs = site.docs | where: "categories","helpers-aws" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.nav_text }}]({{ doc.url }}) 10 | {% endfor %} 11 | 12 | ## Notes 13 | 14 | * By default, `KubeGoogle.logger = Kubes.logger`. This means, you can set `logger.level = "debug"` in `.kubes/config.rb` to see more details. 15 | * The AWS helpers are provided by the [boltops-tools/kubes_aws](https://github.com/boltops-tools/kubes_aws) library. 16 | -------------------------------------------------------------------------------- /docs/_docs/helpers/aws/advanced.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Advanced AWS Helpers 3 | nav_text: Advanced 4 | categories: helpers-aws 5 | --- 6 | 7 | {% assign docs = site.docs | where: "categories","advanced-helpers-aws" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.nav_text }}]({{ doc.url }}) 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /docs/_docs/helpers/builtin.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Core Built-In Helpers 3 | --- 4 | 5 | Kubes provides some helper methods to help write Kubernetes YAML files. Here's a list of the helper methods. These are available whether you write your resources in YAML or DSL. 6 | 7 | Helper | Description 8 | --- | --- 9 | decode64 | Base64 decode a string. 10 | docker_image | Method refers to the latest Docker image built by Kubes. This spares you from having to update the image manually in the deployment resource. Note, this can be overridden with the `--image` cli option or the `Kubes.config.image` setting. See: [Docker Image]({% link _docs/intro/docker-image.md %}) 11 | dockerfile_port | Exposed port extracted from the Dockerfile of the project. 12 | encode64 | Base64 encode a string. Also available as `base64` method. 13 | extra | The `KUBES_EXTRA` value. 14 | with_extra | Appends the `KUBES_EXTRA` value to a string if it's set. It's covered in the [Extra Env Docs]({% link _docs/extra-env.md %}). 15 | 16 | Here's also the source code with most of the helpers: [helpers.rb](https://github.com/boltops-tools/kubes/blob/master/lib/kubes/compiler/shared/helpers.rb). 17 | -------------------------------------------------------------------------------- /docs/_docs/helpers/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom Helpers 3 | --- 4 | 5 | Kubes ships with several built-in helpers. On top of this, you can define your own custom helpers. This allows you to define new methods and customize Kubes further. 6 | 7 | ## Example 8 | 9 | You define custom helpers in the `.kubes/helpers` folder. 10 | 11 | .kubes/helpers/my_helpers.rb 12 | 13 | ```ruby 14 | module MyHelpers 15 | def database_endpoint 16 | case Kubes.env 17 | when "dev" 18 | "dev-db.cbuqdmc3nqvb.us-west-2.rds.amazonaws.com" 19 | when "prod" 20 | "prod-db.cbuqdmc3nqvb.us-west-2.rds.amazonaws.com" 21 | end 22 | end 23 | end 24 | ``` 25 | 26 | The `database_endpoint` will be available to use in the `.kubes/resources` YAML files. IE: 27 | 28 | .kubes/helpers/resources/shared/config_map.yaml 29 | 30 | ```yaml 31 | apiVersion: v1 32 | kind: ConfigMap 33 | metadata: 34 | name: demo 35 | labels: 36 | app: demo 37 | data: 38 | DATABASE_ENDPOINT: <%= database_endpoint %> 39 | ``` 40 | 41 | {% include helpers/generator.md %} -------------------------------------------------------------------------------- /docs/_docs/helpers/google/advanced.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Advanced Google Helpers 3 | nav_text: Advanced 4 | categories: helpers-google 5 | --- 6 | 7 | {% assign docs = site.docs | where: "categories","advanced-helpers-google" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.nav_text }}]({{ doc.url }}) 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /docs/_docs/install.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation 3 | --- 4 | 5 | Here are the ways to install Kubes. 6 | 7 | 1. [Gem]({% link _docs/install/gem.md %}): This is a great way if you already have Ruby on your system. 8 | 2. [Standalone Installer]({% link _docs/install/standalone.md %}): This is a great way if you don't yet have Ruby installed, and want a quick and easy way to install Kubes. There are installers for [Mac OSX]({% link _docs/install/standalone/macosx.md %}), [CentOS]({% link _docs/install/standalone/centos.md %}), [Ubuntu]({% link _docs/install/standalone/ubuntu.md %}), etc. 9 | -------------------------------------------------------------------------------- /docs/_docs/install/dependencies.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Install Dependencies 3 | --- 4 | 5 | These dependencies are not included with any of the installers. This allows you to install and run the versions you want to use. 6 | 7 | 8 | ## kubectl 9 | 10 | Kubes calls kubectl. Kubes has been tested with kubectl v1.15+. Generally, it should work with most versions of kubectl. 11 | 12 | ## docker 13 | 14 | Kubes calls docker. Kubes has been tested with docker 18.x-ce+. Generally, it should work with most versions of docker. 15 | 16 | ## gcloud 17 | 18 | If you are using the [gcloud builder]({% link _docs/config/builder.md %}), set up and configure the [gcloud cli](https://cloud.google.com/sdk/install). 19 | -------------------------------------------------------------------------------- /docs/_docs/install/gem.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Gem Installation 3 | --- 4 | 5 | {% include install/gem.md %} 6 | 7 | -------------------------------------------------------------------------------- /docs/_docs/install/standalone/details.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Standalone Details" 3 | nav_text: Details 4 | category: standalone 5 | order: 9 6 | --- 7 | 8 | The standalone installer packages are built within a few minutes of the kubes gem release. This page covers more details on how the standalone installation works. 9 | 10 | ## Isolated: /opt/kubes 11 | 12 | The standalone kubes package installs kubes in `/opt/kubes`. This folder contains everything like system libraries, Ruby, and gems needed for kubes to work as a standalone package. Additionally, this also makes it easy to remove kubes. 13 | 14 | ## Wrapper: /usr/local/bin 15 | 16 | The installer creates a wrapper script in `/usr/local/bin`. 17 | 18 | /usr/local/bin/kubes 19 | 20 | Most users have `/usr/local/bin` configured in there PATH. So this wrapper should work. 21 | -------------------------------------------------------------------------------- /docs/_docs/install/standalone/details/uninstall.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Uninstall Cleanup" 3 | nav_text: Uninstall 4 | category: standalone-details 5 | order: 4 6 | --- 7 | 8 | Some packager managers will not clean up the installed files completely. The apt-get and yum package manager generally cleans up everything. Homebrew doesn't seem to clean up currently though. 9 | 10 | To fully clean up and uninstall kubes. First, run the package manger uninstall command and then clean up with: 11 | 12 | rm -rf /opt/kubes 13 | 14 | Then remove the kubes wrappers in `/usr/local/bin`. You can remove them with this command: 15 | 16 | grep -l /opt/kubes /usr/local/bin/* | xargs rm -f 17 | -------------------------------------------------------------------------------- /docs/_docs/install/standalone/macosx.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Install: Mac OSX" 3 | nav_text: MacOSX 4 | category: standalone 5 | order: 1 6 | --- 7 | 8 | This page shows you how to install kubes on Mac OSX. 9 | 10 | Here's a "Mac OSX Homebrew Install" Video: 11 | 12 | ## Homebrew 13 | 14 | You can install kubes via homebrew. 15 | 16 | Install 17 | 18 | brew tap boltops-tools/software 19 | brew install kubes 20 | 21 | Upgrade 22 | 23 | brew update 24 | brew install kubes 25 | 26 | Uninstall 27 | 28 | brew uninstall kubes 29 | 30 | Cleanup 31 | 32 | rm -rf /opt/kubes 33 | grep -l /opt/kubes /usr/local/bin/* | xargs rm -f 34 | 35 | {% include install/wrapper.md %} 36 | 37 | ## DMG 38 | 39 | You can also download the dmg and install with the Mac OSX GUI installer. 40 | 41 | Download link: [kubes DMG](https://tap.boltops.com/packages/kubes/kubes-latest.dmg) 42 | 43 | You can check [kubes-latest.dmg.metadata.json](https://tap.boltops.com/packages/kubes/kubes-latest.dmg.metadata.json) to verify the package checksum. Here's the checksum command. 44 | 45 | shasum -a 256 kubes-latest.dmg 46 | -------------------------------------------------------------------------------- /docs/_docs/intro.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: What is Kubes? 3 | --- 4 | 5 | {% include reference.md %} 6 | 7 |
8 | 9 | ## Features 10 | 11 | {% include intro/features.md %} 12 | -------------------------------------------------------------------------------- /docs/_docs/intro/how-kubes-works.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How Kubes Works 3 | --- 4 | 5 | Kubes is pretty straightforward. Kubes first builds the Docker image. Then it compiles Kubernetes YAML files. Lastly, it merely calls out to `kubectl`. 6 | 7 | In fact, you can use Kubes to build the files first, and then run `kubectl` directly. Example: 8 | 9 | kubes docker build 10 | kubes docker push 11 | kubes compile # compiles the .kubes/resources files to .kubes/output 12 | 13 | Now, use `kubectl` directly and apply them in the proper order: 14 | 15 | kubectl apply -f .kubes/output/shared/namespace.yaml 16 | kubectl apply -f .kubes/output/web/service.yaml 17 | kubectl apply -f .kubes/output/web/deployment.yaml 18 | 19 | The deploy command simply does all 3 steps: build, compile, and apply. 20 | 21 | kubes deploy 22 | 23 | Kubes is very transparent about it does. It prints out the `kubectl` commands as they are being called. 24 | 25 | You can also run the `kubectl apply` only. The `kube apply` command compiles but will skip the docker build stage if it's already been built. 26 | 27 | kubes apply 28 | -------------------------------------------------------------------------------- /docs/_docs/intro/ordering/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom Ordering 3 | --- 4 | 5 | You can override the ordering with the `kinds` and `roles` option under the `config.kubectl.order` key. It is fully configurable. Here's an example of overriding the default ordering. 6 | 7 | .kubes/config.rb: 8 | 9 | ```ruby 10 | Kubes.configure do |config| 11 | config.kubectl.order.roles = %w[ 12 | shared 13 | web 14 | worker 15 | clock 16 | ] 17 | config.kubectl.order.kinds = [ 18 | "Namespace", 19 | # ... 20 | "Deployment", 21 | ] 22 | end 23 | ``` 24 | 25 | Items not listed in the list are sorted at the end and in alphabetical order. Refer to the source [ordering.rb](https://github.com/boltops-tools/kubes/blob/master/lib/kubes/config.rb#L50) for the default ordering. 26 | -------------------------------------------------------------------------------- /docs/_docs/layering.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Layering 3 | --- 4 | 5 | Kubes supports layering files together so you can use the same Kubernetes files to build multiple environments like dev and prod. 6 | 7 | {% assign docs = site.docs | where: "categories","layering" | sort: "order" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.title }}]({{ doc.url }}) 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /docs/_docs/layering/dsl.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: DSL Layering 3 | nav_text: DSL 4 | category: layering 5 | order: 2 6 | --- 7 | 8 | {% include layering/layers.md ext="rb" %} 9 | -------------------------------------------------------------------------------- /docs/_docs/layering/extra.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Extra Layering 3 | category: layering 4 | order: 8 5 | --- 6 | 7 | Setting KUBES_EXTRA will process extra layers. 8 | 9 | ## Variables 10 | 11 | Example 12 | 13 | KUBES_EXTRA=2 kubes deploy 14 | 15 | Will process: 16 | 17 | .kubes/variables/dev.rb 18 | .kubes/variables/dev-2.rb 19 | -------------------------------------------------------------------------------- /docs/_docs/layering/yaml.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: YAML Layering 3 | nav_text: YAML 4 | category: layering 5 | order: 1 6 | --- 7 | 8 | {% include layering/layers.md ext="yaml" %} 9 | -------------------------------------------------------------------------------- /docs/_docs/learn/dsl.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getting Started with DSL 3 | --- 4 | 5 | {% include learn/start.md type="DSL" %} 6 | -------------------------------------------------------------------------------- /docs/_docs/learn/dsl/change.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Change Project 3 | --- 4 | 5 | Let's make a simple change. We'll adjust the number of replicas to 3. We do this in `deployment/dev.rb`. 6 | 7 | .kubes/resources/web/deployment/dev.rb 8 | 9 | ```ruby 10 | --- 11 | replicas 3 # <= CHANGED 12 | ``` 13 | 14 | This demonstrates Kubes [Layering support]({% link _docs/layering.md %}). We can make changes to only the `KUBES_DEV` environment. 15 | 16 | Next, we'll deploy this update. 17 | -------------------------------------------------------------------------------- /docs/_docs/learn/dsl/cluster.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Cluster Setup 3 | --- 4 | 5 | {% include learn/cluster.md %} 6 | -------------------------------------------------------------------------------- /docs/_docs/learn/dsl/delete.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Delete App 3 | --- 4 | 5 | Let's now delete the app and clean up: 6 | 7 | kubes delete 8 | 9 | You will be prompted to confirm before deletion. 10 | 11 | $ kubes delete 12 | Compiled .kubes/resources files to .kubes/output 13 | Will run: 14 | kubectl delete -f .kubes/output/web/deployment.yaml 15 | kubectl delete -f .kubes/output/web/service.yaml 16 | kubectl delete -f .kubes/output/shared/namespace.yaml 17 | This will delete resources. Are you sure? (y/N) 18 | 19 | Confirm to delete the resources: 20 | 21 | This will delete resources. Are you sure? (y/N) y 22 | => kubectl delete -f .kubes/output/web/service.yaml 23 | service "demo-web" deleted 24 | => kubectl delete -f .kubes/output/web/deployment.yaml 25 | deployment.apps "demo-web" deleted 26 | => kubectl delete -f .kubes/output/shared/namespace.yaml 27 | namespace "demo" deleted 28 | $ 29 | 30 | Let's double-check that the resources have been deleted: 31 | 32 | $ kubectl get all 33 | No resources found. 34 | $ 35 | 36 | Tip: If you want to delete without the prompt, you can use the `-y` option: 37 | 38 | kubes delete -y 39 | 40 | Next, we'll look at some next steps. 41 | -------------------------------------------------------------------------------- /docs/_docs/learn/dsl/install.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Install Kubes 3 | --- 4 | 5 | {% include install/gem.md %} -------------------------------------------------------------------------------- /docs/_docs/learn/dsl/next-steps.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Next Steps 3 | --- 4 | 5 | {% include learn/next-steps.md %} 6 | -------------------------------------------------------------------------------- /docs/_docs/learn/yaml.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getting Started with YAML 3 | --- 4 | 5 | {% include learn/start.md type="YAML" %} 6 | -------------------------------------------------------------------------------- /docs/_docs/learn/yaml/change.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Change Project 3 | --- 4 | 5 | Let's make a simple change. We'll adjust the number of replicas to 3. We do this in `deployment/dev.yaml`. 6 | 7 | .kubes/resources/web/deployment/dev.yaml 8 | 9 | ```yaml 10 | --- 11 | spec: 12 | replicas: 3 # <= CHANGED 13 | ``` 14 | 15 | This demonstrates Kubes [Layering support]({% link _docs/layering.md %}). We can make changes to only the `KUBES_DEV` environment. 16 | 17 | Next, we'll deploy this update. 18 | -------------------------------------------------------------------------------- /docs/_docs/learn/yaml/cluster.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Cluster Setup 3 | --- 4 | 5 | {% include learn/cluster.md %} 6 | -------------------------------------------------------------------------------- /docs/_docs/learn/yaml/install.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Install Kubes 3 | --- 4 | 5 | {% include install/gem.md %} -------------------------------------------------------------------------------- /docs/_docs/learn/yaml/next-steps.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Next Steps 3 | --- 4 | 5 | {% include learn/next-steps.md %} 6 | -------------------------------------------------------------------------------- /docs/_docs/misc/separate-steps.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Separate Steps 3 | --- 4 | 5 | Sometimes you may want to run the 3 separate kubes steps directly. This may be useful if you are setting up CI/CD and need more control over the build process. Here are the 3 main steps: 6 | 7 | To build and push the docker image: 8 | 9 | kubes docker build 10 | kubes docker push 11 | 12 | Note, you must run a `kubes docker build` at least once. As the build step will store the image name in a `.kubes/state/docker_image.txt ` file for later use. 13 | 14 | To compile the Kubernetes YAML files. 15 | 16 | kubes compile 17 | 18 | To apply the Kubernetes YAML files in the correct order and create resources on the cluster: 19 | 20 | kubes apply 21 | 22 | -------------------------------------------------------------------------------- /docs/_docs/next-steps.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Next Steps 3 | --- 4 | 5 | Hopefully, you have a good feel for how kubes works now. From here, there are a few resources that can help you continue along: 6 | 7 | * Check out the [kubes](https://github.com/boltops-tools/kubes) repo on GitHub 8 | * ⭐️ the kubes project on GitHub 9 | * Write a blog post about kubes 10 | * Post on your favorite discussion about kubes 11 | * Contribute a pull request 12 | 13 | Everyone can contribute to making kubes better, including the documentation. These docs are the kubes repo located the [docs folder](https://github.com/boltops-tools/tree/master/docs). Please fork the project and open a pull request! We love your pull requests. Contributions are encouraged and welcomed! 14 | -------------------------------------------------------------------------------- /docs/_docs/patterns.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Patterns 3 | --- 4 | 5 | We'll cover some common deployment patterns here: 6 | 7 | {% assign docs = site.docs | where: "categories","patterns" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.title }}]({{ doc.url }}) 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /docs/_docs/plugins.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubes Plugins 3 | --- 4 | 5 | Kubes makes it easier to work with Kubernetes by automating the deployment workflow. Many of the conveniences it adds is done with plugins. For example, `aws_secret`, `aws_ssm`, `google_secret` are implemented with Cloud Provider specific Kubes plugins. 6 | 7 | ## Baseline Plugins 8 | 9 | The baseline plugins that currently ship with Kubes are: 10 | 11 | * [kubes_aws]({% link _docs/plugins/aws.md %}) 12 | * [kubes_google]({% link _docs/plugins/google.md %}) 13 | -------------------------------------------------------------------------------- /docs/_docs/plugins/aws.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: AWS Kubes Plugin 3 | --- 4 | 5 | The AWS Kubes Plugin adds support helpers like `aws_secret`. You can configure it's behavior. Example: 6 | 7 | .kubes/config.rb 8 | 9 | ```ruby 10 | KubesAws.configure do |config| 11 | config.secrets.base64 = false 12 | end 13 | ``` 14 | 15 | ## Options Reference Table 16 | 17 | Here's a table with the options: 18 | 19 | Name | Description | Default 20 | ---|---|--- 21 | secrets.base64 | Whether or not to automatically base64 encoded values returned by the `aws_secret` helper. | true 22 | -------------------------------------------------------------------------------- /docs/_docs/plugins/google.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Google Kubes Plugin 3 | --- 4 | 5 | The Google Kubes Plugin adds support helpers like `google_secret`. You can configure it's behavior. Example: 6 | 7 | .kubes/config.rb 8 | 9 | ```ruby 10 | KubesGoogle.configure do |config| 11 | config.secrets.base64 = true 12 | end 13 | ``` 14 | 15 | ## Options Reference Table 16 | 17 | Here's a table with the options: 18 | 19 | Name | Description | Default 20 | ---|---|--- 21 | secrets.base64 | Whether or not to automatically base64 encoded values returned by the `google_secret` helper. | true 22 | {% include plugins/gke-config.md %} -------------------------------------------------------------------------------- /docs/_docs/resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Resources 3 | --- 4 | 5 | You define your Kubernetes resources in the `.kubes/resources` folder. Kubes categories items within this folder in 3 main buckets: 6 | 7 | * [Role-Based Resource]({% link _docs/resources/role.md %}): Role-based resources. This is your main project resources group in roles. 8 | * [Base Folder]({% link _docs/resources/base.md %}): The base folder contains definitions for common fields that is used for [Layering]({% link _docs/layering.md %}). 9 | * [Shared Resources]({% link _docs/resources/shared.md %}): Shared resources that are meant to be created first and shared by other resources. 10 | 11 | In the next sections, we'll cover how these resources are used. 12 | -------------------------------------------------------------------------------- /docs/_docs/resources/base.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Base 3 | --- 4 | 5 | The base folder is used for purely layering. 6 | 7 | ## Structure 8 | 9 | Here's an example structure, so we can understand how layering works with the base folder. 10 | 11 | .kubes/resources/ 12 | ├── base 13 | │ ├── all.rb 14 | │ └── deployment.rb 15 | └── web 16 | ├── deployment.rb 17 | └── service.rb 18 | 19 | ## Layering 20 | 21 | Kubes process the files in the `base` folder first, then it process your [role-based resources]({% link _docs/resources/role.md %}) like web. So: 22 | 23 | kubes deploy web deployment 24 | 25 | Will layer: 26 | 27 | 1. .kubes/resources/base/all.rb 28 | 2. .kubes/resources/base/deployment.rb 29 | 3. .kubes/resources/web/deployment.rb 30 | 31 | More details on layering can be found in the [Layering Docs]({% link _docs/layering.md %}). 32 | 33 | Remember files in the base are used just for layering. 34 | -------------------------------------------------------------------------------- /docs/_docs/resources/role.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Role-Based Resources 3 | --- 4 | 5 | Role-based resources are your main project's resources. Kubes groups resources together under a "role". 6 | 7 | ## Example Structure 8 | 9 | Here's an example structure to help explain how role-based resources work. 10 | 11 | .kubes/resources 12 | ├── clock 13 | │ └── deployment.yaml 14 | ├── web 15 | │ ├── deployment.yaml 16 | │ └── service.yaml 17 | └── worker 18 | └── deployment.yaml 19 | 20 | ## Resource Roles 21 | 22 | Here the resource roles are: 23 | 24 | 1. clock 25 | 2. web 26 | 3. worker 27 | 28 | You can freely add more roles if needed. This structure is flexible enough to account for most use-cases. 29 | 30 | ## Deploy 31 | 32 | You can deploy specific roles like so: 33 | 34 | kubes deploy clock 35 | kubes deploy web 36 | kubes deploy worker 37 | 38 | Or you can deploy all roles at once: 39 | 40 | kubes deploy 41 | -------------------------------------------------------------------------------- /docs/_docs/variables.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Variables 3 | --- 4 | 5 | You can set variables to be made available to the templates. Generally, it is recommended to use Basic layering. 6 | 7 | {% assign docs = site.docs | where: "categories","variables" %} 8 | {% for doc in docs -%} 9 | * [{{ doc.title }}]({{ doc.url }}) 10 | {% endfor %} 11 | 12 | {% include variables/generator.md %} -------------------------------------------------------------------------------- /docs/_docs/vs.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubes vs. Other Tools 3 | --- 4 | 5 | {% include videos/learn/vs.md %} 6 | 7 | Here are some useful comparisons to help you compare Kubes vs other tools in the ecosystem: 8 | 9 | {% assign docs = site.docs | where: "categories","vs" %} 10 | {% for doc in docs -%} 11 | * [{{ doc.nav_text }}]({{ doc.url }}) 12 | {% endfor %} 13 | -------------------------------------------------------------------------------- /docs/_docs/yaml.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubes YAML 3 | --- 4 | 5 | You can write your Kubernetes resources in YAML format. 6 | 7 | .kubes/resources 8 | └── web 9 | ├── deployment.yaml 10 | └── service.yaml 11 | 12 | ## YAML and Templating 13 | 14 | Kubes provides a little extra power for the YAML format. The YAML files are processed through an ERB templating language. So you have dynamic control. Here's an example with `Kubes.env` and the `docker_image` helper. 15 | 16 | .kubes/resources/web/deployment.yaml 17 | 18 | ```yaml 19 | --- 20 | apiVersion: apps/v1 21 | kind: Deployment 22 | metadata: 23 | name: demo-web 24 | labels: 25 | app: demo 26 | namespace: default 27 | spec: 28 | replicas: <%= Kubes.env == "prod" ? 2 : 1 %> 29 | selector: 30 | matchLabels: 31 | app: demo 32 | template: 33 | metadata: 34 | labels: 35 | app: demo 36 | spec: 37 | containers: 38 | - name: demo-web 39 | image: <%= docker_image %> 40 | ``` 41 | -------------------------------------------------------------------------------- /docs/_docs/yaml/multiple-files.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: YAML Multiple Resources with Multiple Files 3 | --- 4 | 5 | You can also create multiple resources of same kind by appending a dash followed by anything. Example: 6 | 7 | .kubes/resources 8 | └── web 9 | ├── deployment-1.yaml 10 | ├── deployment-2.yaml 11 | ├── service-1.yaml 12 | └── service-2.yaml 13 | 14 | Only words before the dash are used to infer the resource kind. 15 | 16 | Filename | Resource Kind 17 | --- | --- 18 | deployment-1.yaml | Deployment 19 | deployment-2.yaml | Deployment 20 | service-1.yaml | Service 21 | service-2.yaml | Service 22 | 23 | -------------------------------------------------------------------------------- /docs/_includes/banner/foot.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | -------------------------------------------------------------------------------- /docs/_includes/config/hooks/generator.md: -------------------------------------------------------------------------------- 1 | ## Hook Generator 2 | 3 | To generator a starter hook: 4 | 5 | $ kubes new hook {{ include.type }} 6 | create .kubes/config/hooks/{{ include.type }}.rb 7 | -------------------------------------------------------------------------------- /docs/_includes/config/hooks/options.md: -------------------------------------------------------------------------------- 1 | ## General Form 2 | 3 | ```ruby 4 | before(COMMAND_NAME, OPTIONS) 5 | ```` 6 | 7 | The command name corresponds to the `{{ include.command }}` commands: apply, delete, etc. 8 | 9 | ## Hook Options 10 | 11 | Name | Description 12 | ---|--- 13 | label | A human-friendly label so you can see what hooks is being run. 14 | execute | The script or command to run. IE: path/to/some/script.sh 15 | exit_on_fail | Whether or not to continue process if the script returns an failed exit code. 16 | {% if include.command == "kubectl" %}on | What resource to run the hook on. IE: shared/namespace, web/deployment, web/service. Note: This option is only used by kubectl hooks.{% endif %} 17 | 18 | ## Ruby Hooks 19 | 20 | Instead of using a script for the hook `execute` option, you can also use a Ruby object. This provides some more control over the current process. See: [Ruby Hooks]({% link _docs/config/hooks/ruby.md %}) 21 | 22 | -------------------------------------------------------------------------------- /docs/_includes/content.html: -------------------------------------------------------------------------------- 1 | {% if page.sidebar == false %} 2 | 3 | {{ content }} 4 | 5 | {% else %} 6 | 7 |
8 | {% include_cached sidebar.html %} 9 |
10 | 17 | 18 |
19 |

{{ page.title }}

20 | {{ content }} 21 |
22 |
23 |
24 | 25 | {% endif %} 26 | -------------------------------------------------------------------------------- /docs/_includes/dsl/methods.md: -------------------------------------------------------------------------------- 1 | For a full list of the available methods, refer to the source itself [syntax/{{ include.name }}.rb](https://github.com/boltops-tools/kubes/blob/master/lib/kubes/compiler/dsl/syntax/{{ include.name }}.rb). 2 | -------------------------------------------------------------------------------- /docs/_includes/dsl/rolling_deployment.md: -------------------------------------------------------------------------------- 1 | A suffix hash based on the contents of the {{ include.kind }} is automatically appended to the {{ include.kind }} name. {{ include.kind }}s used in Deployment and Pod containers fields that use the same name will also have the suffix automatically appended. This is done to trigger a rolling deployment. Here's an example an deployment output with the hashed name. 2 | -------------------------------------------------------------------------------- /docs/_includes/dsl/suffix_hash.md: -------------------------------------------------------------------------------- 1 | You can disable the auto hasher behavior with: 2 | 3 | ```ruby 4 | Kubes.configure do |config| 5 | # ... 6 | config.suffix_hash = false 7 | end 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/_includes/example.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

TODO

6 |
7 |
8 |
9 | 10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /docs/_includes/google_analytics.html: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /docs/_includes/helpers/base64.md: -------------------------------------------------------------------------------- 1 | Note, Kubernetes secrets are only base64 encoded. So users who have access to read Kubernetes secrets will be able to decode and get the value trivially. Depending on your security posture requirements, this may or may not suffice. 2 | -------------------------------------------------------------------------------- /docs/_includes/helpers/generator.md: -------------------------------------------------------------------------------- 1 | ## Generator 2 | 3 | To help you get started quickly, you can generate starter helper code. 4 | 5 | $ kubes new helper custom 6 | create .kubes/helpers/custom_helper.rb 7 | 8 | .kubes/helpers/custom_helper.rb 9 | 10 | ```ruby 11 | module CustomHelper 12 | end 13 | ``` -------------------------------------------------------------------------------- /docs/_includes/install/gem.md: -------------------------------------------------------------------------------- 1 | ## RubyGems 2 | 3 | Install kubes via RubyGems. 4 | 5 | gem install kubes 6 | 7 | Ruby 3.0 and above is recommended. For other ways to install Kubes see: [Install Docs]({% link _docs/install.md %}). 8 | -------------------------------------------------------------------------------- /docs/_includes/install/wrapper.md: -------------------------------------------------------------------------------- 1 | ## Generated Wrapper 2 | 3 | The standalone installer creates a wrapper script in `/usr/local/bin`. 4 | 5 | /usr/local/bin/kubes 6 | 7 | Most users have `/usr/local/bin` configured in their PATH. So this wrapper should work immediately. 8 | 9 | Important: If you have a wrapper in `/usr/local/bin` already, the installer will overwrite it. 10 | -------------------------------------------------------------------------------- /docs/_includes/js.html: -------------------------------------------------------------------------------- 1 | {% if site.google_analytics and jekyll.environment == "production" %} 2 | {% include google_analytics.html %} 3 | {% endif %} 4 | -------------------------------------------------------------------------------- /docs/_includes/kubes-steps.md: -------------------------------------------------------------------------------- 1 | 1. Build the docker image and push it to repo 2 | 2. Compile Kubernetes YAML files with the Docker build image 3 | 3. Deploy via kubectl apply on the compiled Kubernetes YAML files -------------------------------------------------------------------------------- /docs/_includes/learn/next-steps.md: -------------------------------------------------------------------------------- 1 | You've seen how to get started with Kubes. From here, you can check out the Docs to learn more: 2 | 3 | * [Intro]({% link _docs/intro.md %}): General introduction. 4 | * [Layering]({% link _docs/layering.md %}): Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering]({% link _docs/layering.md %}). 5 | * [CLI Customizations]({% link _docs/config.md %}): You can customize the [cli args]({% link _docs/config/kubectl.md %}). You can also run hooks before and after kubectl commands. 6 | * [Extra Env]({% link _docs/extra-env.md %}): Create additional envs with little effort. 7 | 8 | ## Learn Videos 9 | 10 | Watch BoltOps Learn Kubes videos: 11 | 12 | * [BoltOps Learn Kubes Videos](https://learn.boltops.com/tagged/kubes) 13 | 14 | 15 | ## Kubes Features 16 | 17 | {% include intro/features.md %} 18 | -------------------------------------------------------------------------------- /docs/_includes/learn/repo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/_includes/learn/repo -------------------------------------------------------------------------------- /docs/_includes/learn/repos.md: -------------------------------------------------------------------------------- 1 | For this tutorial, here are examples of AWS ECR and Google GCR repos, though any repo will work. 2 | 3 | AWS: 4 | 5 | REPO=$(aws ecr describe-repositories --repository-name demo | jq -r '.repositories[].repositoryUri') 6 | 7 | Google: 8 | 9 | export GOOGLE_PROJECT=project-123 10 | REPO=gcr.io/$GOOGLE_PROJECT/demo 11 | -------------------------------------------------------------------------------- /docs/_includes/learn/review.md: -------------------------------------------------------------------------------- 1 | ## Config 2 | 3 | The `config.rb` is where you can configure Kubes settings. 4 | 5 | .kubes/config.rb 6 | 7 | ```ruby 8 | Kubes.configure do |config| 9 | config.repo = "112233445566.dkr.ecr.us-west-2.amazonaws.com/demo" # may be gcr.io/project-123/demo 10 | config.logger.level = "info" 11 | # auto-switching 12 | # config.kubectl.context = "dev-cluster" 13 | end 14 | ``` 15 | 16 | This is where the `--repo` from `kubes init` got saved. The other options are covered in the [Env Config Docs]({% link _docs/config/env.md %}). 17 | 18 | ## Dockerfile 19 | 20 | The `Dockerfile` is a simple starter example that just runs nginx 21 | 22 | Dockerfile: 23 | 24 | # Simple example starter 25 | FROM nginx 26 | EXPOSE 80 27 | CMD ["nginx", "-g", "daemon off;"] 28 | 29 | Note: If your project already has a Dockerfile, kubes will use that instead of generating a starter one. 30 | -------------------------------------------------------------------------------- /docs/_includes/learn/start.md: -------------------------------------------------------------------------------- 1 | Kubes is a Kubernetes deployment tool. It automates the deployment process. 2 | 3 | In this guide we'll build a docker image, and build kubernetes YAML files, and deploy a demo app. We'll use the {{ include.type }} format. 4 | -------------------------------------------------------------------------------- /docs/_includes/plugins/gke-config.md: -------------------------------------------------------------------------------- 1 | gke.cluster_name | GKE cluster name. This is required when using the [GKE whitelisting feature]({% link _docs/helpers/google/gke.md %}). | nil 2 | gke.enable_get_credentials | Whether or not to run the hook that calls `gcloud container clusters get-credentials`. This spares you from having to call it manually. | false 3 | gke.enable_hooks | This will be true when the cluster_name is set. So there's no need to set it. The option provides a quick way to override and disable running the hooks. | true 4 | gke.google_project | Google project. Can also be set with the env var `GOOGLE_PROJECT`. `GOOGLE_PROJECT` takes precedence. | nil 5 | gke.google_region | Google region cluster is in. Can also be set with the env var `GOOGLE_REGION`. `GOOGLE_REGION` takes precedence. | nil 6 | gke.whitelist_ip | Explicit IP to whitelist. By default the IP address of the current machine is automatically detected and used. | nil -------------------------------------------------------------------------------- /docs/_includes/reference.md: -------------------------------------------------------------------------------- 1 | Kubes is a Kubernetes deployment tool. It focuses on deploying your specific application. It is very good at automating the deployment process. Kubes will: 2 | 3 | {% include kubes-steps.md %} -------------------------------------------------------------------------------- /docs/_includes/variables/generator.md: -------------------------------------------------------------------------------- 1 | ## Generator 2 | 3 | To help you get started quickly, you can generate starter variable code. 4 | 5 | $ kubes new variable 6 | create .kubes/variables/dev.rb 7 | 8 | .kubes/variables/dev.rb 9 | 10 | ```ruby 11 | @example = "dev-value" 12 | ``` 13 | 14 | To create the prod variables, set `KUBES_ENV=prod`. 15 | 16 | $ KUBES_ENV=prod kubes new variable 17 | create .kubes/variables/prod.rb 18 | 19 | .kubes/variables/prod.rb 20 | 21 | ```ruby 22 | @example = "prod-value" 23 | ``` 24 | -------------------------------------------------------------------------------- /docs/_includes/videos/learn.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | {% if include.img %} 4 | 5 | {% else %} 6 | 7 | {% endif %} 8 | 9 | {% unless include.premium == false %} 10 |
Note: Premium video content requires a subscription.
11 | {% endunless %} 12 |
13 | -------------------------------------------------------------------------------- /docs/_includes/videos/learn/vs.md: -------------------------------------------------------------------------------- 1 | {% include videos/learn.md 2 | url="kubernetes-deploy-tools/lessons/kubernetes-tools-kustomize-vs-helm-vs-kubes" 3 | img="https://uploads-learn.boltops.com/7bvtooupw8qru86ily4uyrj3mwuf" 4 | premium=false %} -------------------------------------------------------------------------------- /docs/_includes/videos/youtube.md: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /docs/_includes/vs/article.md: -------------------------------------------------------------------------------- 1 | This article also covers more differences in detail: [Kustomize vs Helm vs Kubes: Kubernetes Deploy Tools](https://blog.boltops.com/2020/11/05/kustomize-vs-helm-vs-kubes-kubernetes-deploy-tools) -------------------------------------------------------------------------------- /docs/_includes/vs/kubes/layering.md: -------------------------------------------------------------------------------- 1 | ### Kubes Layering 2 | 3 | To deploy and create multiple environments like dev and prod with the same YAML, we use a different KUBES_ENV setting: 4 | 5 | KUBES_ENV=dev kubes deploy 6 | KUBES_ENV=prod kubes deploy 7 | 8 | The layering is achieved thanks to the conventional project structure. You don't have to do any extra work, you just create pre-process base layer files or post-process environment specific layer files. 9 | 10 | * [Kubes Layering Docs]({% link _docs/layering.md %}) 11 | -------------------------------------------------------------------------------- /docs/_includes/vs/kubes/structure.md: -------------------------------------------------------------------------------- 1 | ### Kubes Project Structure 2 | 3 | On the other hand, Kubes defines a conventional project structure. Here's a project directory example: 4 | 5 | .kubes/resources 6 | ├── base 7 | │ ├── all.yaml 8 | │ └── deployment.yaml 9 | ├── shared 10 | │ └── namespace.yaml 11 | └── web 12 | ├── deployment 13 | │ ├── dev.yaml 14 | │ └── prod.yaml 15 | ├── deployment.yaml 16 | └── service.yaml 17 | 18 | A Kubes project structure also supports introduces a role concept or folder. The folder structure only shows a web role for simplicity. You can always add more roles. For example: 19 | 20 | .kubes/resources/ROLE/deployment.yaml 21 | .kubes/resources/clock/deployment.yaml 22 | .kubes/resources/web/deployment.yaml 23 | .kubes/resources/worker/deployment.yaml 24 | -------------------------------------------------------------------------------- /docs/_reference/kubes-apply.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes apply 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes apply [ROLE] [RESOURCE] 9 | 10 | ## Description 11 | 12 | Apply the Kubernetes YAML files without building docker image 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--image=IMAGE] # override image 19 | [--compile], [--no-compile] # whether or not to compile the .kube/resources 20 | # Default: true 21 | [--verbose], [--no-verbose] 22 | [--noop], [--no-noop] 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /docs/_reference/kubes-clean.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes clean 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes clean 9 | 10 | ## Description 11 | 12 | Remove .kubes/output files 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--image=IMAGE] # override image 19 | [--verbose], [--no-verbose] 20 | [--noop], [--no-noop] 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /docs/_reference/kubes-compile.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes compile 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes compile 9 | 10 | ## Description 11 | 12 | Compile Kubernetes YAML files from DSL 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--image=IMAGE] # override image 19 | [--verbose], [--no-verbose] 20 | [--noop], [--no-noop] 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /docs/_reference/kubes-completion.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes completion 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes completion *PARAMS 9 | 10 | ## Description 11 | 12 | Prints words for auto-completion. 13 | 14 | ## Examples 15 | 16 | kubes completion 17 | 18 | Prints words for TAB auto-completion. 19 | 20 | kubes completion 21 | kubes completion hello 22 | kubes completion hello name 23 | 24 | To enable, TAB auto-completion add the following to your profile: 25 | 26 | eval $(kubes completion_script) 27 | 28 | Auto-completion example usage: 29 | 30 | kubes [TAB] 31 | kubes hello [TAB] 32 | kubes hello name [TAB] 33 | kubes hello name --[TAB] 34 | 35 | 36 | ## Options 37 | 38 | ``` 39 | [--verbose], [--no-verbose] 40 | [--noop], [--no-noop] 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /docs/_reference/kubes-completion_script.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes completion_script 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes completion_script 9 | 10 | ## Description 11 | 12 | Generates a script that can be eval to setup auto-completion. 13 | 14 | To use, add the following to your `~/.bashrc` or `~/.profile` 15 | 16 | eval $(kubes completion_script) 17 | 18 | 19 | ## Options 20 | 21 | ``` 22 | [--verbose], [--no-verbose] 23 | [--noop], [--no-noop] 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /docs/_reference/kubes-delete.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes delete 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes delete [ROLE] [RESOURCE] 9 | 10 | ## Description 11 | 12 | Delete Kubernetes resources in defined .kubes/resources 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--image=IMAGE] # override image 19 | y, [--yes], [--no-yes] # Skip are you sure prompt 20 | [--verbose], [--no-verbose] 21 | [--noop], [--no-noop] 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /docs/_reference/kubes-deploy.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes deploy 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes deploy [ROLE] [RESOURCE] 9 | 10 | ## Description 11 | 12 | Deploy to Kubernetes: docker build/push, kubes compile, and kubectl apply 13 | 14 | ## Examples 15 | 16 | Deploy all resources in .kubes/resources/web 17 | 18 | kubes deploy web 19 | 20 | Deploy specific resource, like .kubes/resources/web/deployment.rb 21 | 22 | kubes deploy web deployment 23 | kubes deploy web service 24 | 25 | 26 | ## Options 27 | 28 | ``` 29 | [--image=IMAGE] # override image 30 | [--build], [--no-build] # whether or not to build docker image 31 | # Default: true 32 | [--verbose], [--no-verbose] 33 | [--noop], [--no-noop] 34 | ``` 35 | 36 | -------------------------------------------------------------------------------- /docs/_reference/kubes-describe.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes describe 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes describe [ROLE] [RESOURCE] 9 | 10 | ## Description 11 | 12 | Describe Kubernetes resource using the compiled YAML files 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--image=IMAGE] # override image 19 | [--compile], [--no-compile] # whether or not to compile the .kube/resources 20 | # Default: true 21 | [--verbose], [--no-verbose] 22 | [--noop], [--no-noop] 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /docs/_reference/kubes-docker-build.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes docker build 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes docker build 9 | 10 | ## Description 11 | 12 | Build docker image. 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--push], [--no-push] 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /docs/_reference/kubes-docker-help.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes docker help 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes docker help [COMMAND] 9 | 10 | ## Description 11 | 12 | Describe subcommands or one specific subcommand 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/_reference/kubes-docker-push.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes docker push 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes docker push IMAGE 9 | 10 | ## Description 11 | 12 | Push the docker image. 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--push], [--no-push] 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /docs/_reference/kubes-docker.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes docker 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes docker SUBCOMMAND 9 | 10 | ## Description 11 | 12 | Docker subcommands 13 | 14 | ## Subcommands 15 | 16 | * [kubes docker build]({% link _reference/kubes-docker-build.md %}) - Build docker image. 17 | * [kubes docker push]({% link _reference/kubes-docker-push.md %}) - Push the docker image. 18 | 19 | ## Options 20 | 21 | ``` 22 | [--verbose], [--no-verbose] 23 | [--noop], [--no-noop] 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /docs/_reference/kubes-get.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes get 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes get [ROLE] [RESOURCE] 9 | 10 | ## Description 11 | 12 | Get Kubernetes resource using the compiled YAML files 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--image=IMAGE] # override image 19 | [--compile], [--no-compile] # whether or not to compile the .kube/resources 20 | # Default: true 21 | o, [--output=OUTPUT] # Output format: json|yaml|wide|name 22 | [--show-pods], [--no-show-pods] # Also show pods from deployments 23 | # Default: true 24 | [--verbose], [--no-verbose] 25 | [--noop], [--no-noop] 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /docs/_reference/kubes-init.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes init 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes init --repo=REPO a, --app=APP 9 | 10 | ## Description 11 | 12 | Init project 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | a, --app=APP # Docker repo name. Example: web. Generates .kubes/APP/resources folder 19 | y, [--force] # Bypass overwrite are you sure prompt for existing files 20 | t, [--type=TYPE] # Type: dsl or yaml 21 | # Default: yaml 22 | --repo=REPO # Docker repo name. Example: user/repo. Configures .kubes/config.rb 23 | n, [--namespace=NAMESPACE] # Namespace to use, defaults to APP-ENV. IE: demo-dev 24 | [--verbose], [--no-verbose] 25 | [--noop], [--no-noop] 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /docs/_reference/kubes-logs.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes logs 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes logs 9 | 10 | ## Description 11 | 12 | logs from all deployment pods 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--compile], [--no-compile] # whether or not to compile the .kube/resources 19 | # Default: true 20 | p, [--pod=POD] # pod to use. IE: web 21 | d, [--deployment=DEPLOYMENT] # deployment name to use. IE: demo-web 22 | c, [--container=CONTAINER] # Container name. If omitted, the first container in the pod will be chosen 23 | f, [--follow], [--no-follow] # Follow logs 24 | # Default: true 25 | [--verbose], [--no-verbose] 26 | [--noop], [--no-noop] 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /docs/_reference/kubes-new-help.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes new help 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes new help [COMMAND] 9 | 10 | ## Description 11 | 12 | Describe subcommands or one specific subcommand 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/_reference/kubes-new-helper.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes new helper 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes new helper 9 | 10 | ## Description 11 | 12 | Generates kubes helper file. 13 | 14 | ## Examples 15 | 16 | $ kubes new helper custom 17 | create .kubes/helpers/custom_helper.rb 18 | 19 | 20 | ## Options 21 | 22 | ``` 23 | y, [--force] # Bypass overwrite are you sure prompt for existing files 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /docs/_reference/kubes-new-hook.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes new hook 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes new hook 9 | 10 | ## Description 11 | 12 | Generates kubes hook file. 13 | 14 | ## Examples 15 | 16 | $ kubes new hook docker 17 | create .kubes/config/hooks/docker.rb 18 | $ kubes new hook kubectl 19 | create .kubes/config/hooks/kubectl.rb 20 | $ kubes new hook kubes 21 | create .kubes/config/hooks/kubes.rb 22 | $ 23 | 24 | 25 | ## Options 26 | 27 | ``` 28 | y, [--force] # Bypass overwrite are you sure prompt for existing files 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /docs/_reference/kubes-new-variable.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes new variable 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes new variable 9 | 10 | ## Description 11 | 12 | Generates kubes variable file. 13 | 14 | ## Examples 15 | 16 | $ kubes new variable 17 | create .kubes/variables/dev.rb 18 | $ KUBES_ENV=prod kubes new variable 19 | create .kubes/variables/prod.rb 20 | 21 | 22 | ## Options 23 | 24 | ``` 25 | y, [--force] # Bypass overwrite are you sure prompt for existing files 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /docs/_reference/kubes-new.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes new 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes new 9 | 10 | ## Description 11 | 12 | Generates new resource. 13 | 14 | ## Subcommands 15 | 16 | * [kubes new helper]({% link _reference/kubes-new-helper.md %}) - Generates kubes helper file. 17 | * [kubes new hook]({% link _reference/kubes-new-hook.md %}) - Generates kubes hook file. 18 | * [kubes new resource]({% link _reference/kubes-new-resource.md %}) - Generates Kubes Kubernetes resource definition. 19 | * [kubes new variable]({% link _reference/kubes-new-variable.md %}) - Generates kubes variable file. 20 | 21 | ## Options 22 | 23 | ``` 24 | [--verbose], [--no-verbose] 25 | [--noop], [--no-noop] 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /docs/_reference/kubes-prune.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes prune 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes prune 9 | 10 | ## Description 11 | 12 | Prune old resources like secret and config maps 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | y, [--yes], [--no-yes] # Skip are you sure prompt 19 | [--verbose], [--no-verbose] 20 | [--noop], [--no-noop] 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /docs/_reference/kubes-version.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: kubes version 3 | reference: true 4 | --- 5 | 6 | ## Usage 7 | 8 | kubes version 9 | 10 | ## Description 11 | 12 | prints version 13 | 14 | 15 | ## Options 16 | 17 | ``` 18 | [--verbose], [--no-verbose] 19 | [--noop], [--no-noop] 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /docs/_sass/bootstrap-overrides.scss: -------------------------------------------------------------------------------- 1 | // Bootstrap overrides for this template 2 | .bg-primary { 3 | // background: $theme-primary; 4 | // background: -webkit-linear-gradient($theme-primary, darken($theme-primary, 5%)); 5 | // background: linear-gradient(#c70000, darken($theme-primary, 5%)); 6 | background-color: #730c0c !important; 7 | } 8 | 9 | .text-primary { 10 | color: $theme-primary; 11 | } 12 | 13 | .no-gutter > [class*='col-'] { 14 | padding-right: 0; 15 | padding-left: 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /docs/_sass/caret.scss: -------------------------------------------------------------------------------- 1 | /*https://www.w3schools.com/howto/howto_js_treeview.asp*/ 2 | 3 | .caret { 4 | cursor: pointer; 5 | -webkit-user-select: none; /* Safari 3.1+ */ 6 | -moz-user-select: none; /* Firefox 2+ */ 7 | -ms-user-select: none; /* IE 10+ */ 8 | user-select: none; 9 | font-family: initial; 10 | } 11 | 12 | .caret::before { 13 | content: "\25B6"; 14 | // note: using font-family other than -apple-system makes the macos-ish look sidebar cursor on the iphone on chrome and safari. 15 | font-family: -apple-system; // so care 16 | color: #5d5353; 17 | display: inline-block; 18 | margin-right: 8px; 19 | } 20 | 21 | .caret-down::before { 22 | -ms-transform: rotate(90deg); /* IE 9 */ 23 | transform: rotate(90deg); 24 | } 25 | 26 | // to align the menu items 27 | .caret-spacing::before { 28 | content: "\25B6"; // so we can keep the same width 29 | color: white; // matches with background so cannot be seen 30 | } 31 | 32 | .nested { 33 | display: none; 34 | } 35 | 36 | .active { 37 | display: block; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /docs/_sass/content.scss: -------------------------------------------------------------------------------- 1 | // https://www.w3schools.com/howto/howto_css_menu_icon.asp 2 | .menu-top-bar { 3 | padding: 15px; // to match with .container-fluid 15px 4 | } 5 | #menu-toggle { 6 | .bar1, .bar2, .bar3 { 7 | width: 24px; 8 | height: 2px; 9 | background-color: #333; 10 | margin: 6px 0; 11 | transition: 0.4s; 12 | } 13 | } 14 | 15 | #content { 16 | width: 100%; 17 | max-width: 900px; 18 | padding: 5px; // .container-fluid has 15px already 19 | min-height: 85vh; // not 100vh so footer shows a little bit 20 | transition: all 0.3s; 21 | } 22 | -------------------------------------------------------------------------------- /docs/_sass/cta.scss: -------------------------------------------------------------------------------- 1 | // Styling for the call to action section 2 | section.cta { 3 | position: relative; 4 | padding: 50px 0; 5 | text-align: center; 6 | margin: 0 auto; 7 | background-position: center; 8 | @include background-cover; 9 | .cta-content { 10 | position: relative; 11 | z-index: 1; 12 | h2 { 13 | text-align: center; 14 | margin: 0 auto 25px auto; 15 | font-size: 50px; 16 | font-weight: 200; 17 | max-width: 450px; 18 | color: white; 19 | border: none; 20 | } 21 | @media (min-width: 768px) { 22 | h2 { 23 | text-align: center; 24 | margin: 0 auto; 25 | font-size: 80px; 26 | border: none; 27 | font-weight: 200; 28 | } 29 | } 30 | } 31 | .overlay { 32 | position: absolute; 33 | top: 0; 34 | left: 0; 35 | width: 100%; 36 | height: 100%; 37 | background-color: #730c0c; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /docs/_sass/table.scss: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | max-width: 900px; 4 | margin-bottom: 20px; 5 | border: 1px solid #dfe2e5; 6 | } 7 | 8 | tr:nth-child(2n) { 9 | background-color: #f6f8fa; 10 | } 11 | 12 | td { 13 | vertical-align: top; 14 | border: 1px solid #dfe2e5; 15 | } 16 | 17 | th, td { 18 | padding: 10px; 19 | } 20 | 21 | thead th { 22 | background-color: #000000; 23 | text-transform: uppercase; 24 | color: #cdcdce; 25 | } 26 | 27 | tbody td { 28 | box-shadow: inset 0 1px 0 rgba(255,255,255,0.1); 29 | color: black; 30 | } -------------------------------------------------------------------------------- /docs/_sass/variables.scss: -------------------------------------------------------------------------------- 1 | // Variables 2 | 3 | // Gray and Brand Colors for use across theme 4 | 5 | $theme-primary: #777; 6 | $theme-secondary: #7b4397; 7 | $theme-tertiary: #dc2430; 8 | 9 | $gray-base: #000; 10 | $gray-darker: lighten($gray-base, 13.5%); // #222 11 | $gray-dark: lighten($gray-base, 20%); // #333 12 | $gray: lighten($gray-base, 33.5%); // #555 13 | $gray-light: lighten($gray-base, 46.7%); // #777 14 | $gray-lighter: lighten($gray-base, 93.5%); // #eee 15 | 16 | $brand-twitter: #1da1f2; 17 | $brand-facebook: #3b5998; 18 | $brand-google-plus: #dd4b39; 19 | 20 | $site-color-primary: #3972c7; 21 | $site-color-primary-rgb: #18FF9C; 22 | $site-color-secondary: #2c3e50; 23 | $site-color-secondary-dark: #233140; 24 | $site-color-links: #a3c8ff; 25 | -------------------------------------------------------------------------------- /docs/bin/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bundle exec jekyll build 4 | bundle exec rake opal:build -------------------------------------------------------------------------------- /docs/bin/rerun: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec bundle exec rerun -x --background --pattern 'opal/*.rb' 'rake opal:build' -------------------------------------------------------------------------------- /docs/bin/web: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | # Usage: 4 | # bin/web 5 | # bin/web -P 8888 6 | 7 | bundle exec jekyll clean 8 | exec bundle exec jekyll serve --trace --config _config.yml --port 4002 --host 0.0.0.0 "$@" 9 | -------------------------------------------------------------------------------- /docs/css/main.scss: -------------------------------------------------------------------------------- 1 | --- 2 | # this ensures Jekyll reads the file to be transformed into CSS later 3 | # only Main files contain this front matter, not partials. 4 | --- 5 | 6 | // base 7 | @import "variables"; 8 | @import "mixins"; 9 | @import "default"; 10 | 11 | // structure 12 | @import "sidebar"; 13 | @import "caret"; 14 | @import "content"; 15 | @import "footer"; 16 | 17 | // theme 18 | @import "bootstrap-overrides"; 19 | @import "theme"; 20 | @import "buttons"; 21 | @import "masthead"; 22 | @import "table"; 23 | @import "syntax"; 24 | @import "cta"; 25 | -------------------------------------------------------------------------------- /docs/docs.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | 5 | ## What is kubes? 6 | 7 | {% include reference.md %} 8 | -------------------------------------------------------------------------------- /docs/getting-started.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getting Started 3 | --- 4 | 5 | Kubes makes it easier to work with Kubernetes by automating the deployment workflow. It will: 6 | 7 | {% include kubes-steps.md %} 8 | 9 | Choose an option: 10 | 11 | 1. [Getting Started with Kubes YAML]({% link _docs/learn/yaml.md %}) 12 | 2. [Getting Started with Kubes DSL]({% link _docs/learn/dsl.md %}) 13 | -------------------------------------------------------------------------------- /docs/img/logos/boltops-logo-full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/img/logos/boltops-logo-full.png -------------------------------------------------------------------------------- /docs/img/logos/boltops-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/img/logos/boltops-logo.png -------------------------------------------------------------------------------- /docs/img/logos/filler-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/img/logos/filler-logo.png -------------------------------------------------------------------------------- /docs/img/logos/kubes-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/img/logos/kubes-black.png -------------------------------------------------------------------------------- /docs/img/logos/kubes-sign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/img/logos/kubes-sign.png -------------------------------------------------------------------------------- /docs/img/logos/kubes-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/img/logos/kubes-white.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | sidebar: false 4 | --- 5 | 6 |
7 |
8 |
9 |
10 |
11 |
12 |

Kubes: Kubernetes App Deploy Tool

13 |

Kubes is a Kubernetes App Deployment Tool. It focuses on deploying your specific application. It builds the docker image, creates the Kubernetes YAML, and runs kubectl apply. It automates the deployment process and saves you precious finger-typing energy.

14 |
15 |
16 |
17 |
18 | 19 |
20 |
21 |
22 |
23 | 24 | {% include commands.html %} 25 | 26 |
27 |
28 |
29 |

Learn More

30 | Quick Start 31 |
32 |
33 |
34 |
35 | -------------------------------------------------------------------------------- /docs/js/scripts.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | // adjust edit-page link 3 | var github_base = $('#edit-page').attr('href'); 4 | var md_page = window.location.pathname.replace('/','_').replace(/\/$/,'.md'); 5 | var href = github_base + md_page; 6 | $('#edit-page').attr('href', href); 7 | }); 8 | -------------------------------------------------------------------------------- /docs/opal/app.rb: -------------------------------------------------------------------------------- 1 | # client-side require. Note: the server-side requires are in the Rakefile 2 | require "opal" 3 | require "opal-jquery" 4 | require "browser" 5 | require "browser/location" 6 | require "native" 7 | require "sidebar" 8 | require "pager" 9 | 10 | # use bin/rerun to continuously generate js/app.js from this file 11 | 12 | Document.ready? do 13 | Sidebar.setup 14 | Pager.setup 15 | end 16 | 17 | -------------------------------------------------------------------------------- /docs/reference.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: CLI Reference 3 | --- 4 | {% include reference.md %} 5 | 6 | * [kubes apply]({% link _reference/kubes-apply.md %}) 7 | * [kubes clean]({% link _reference/kubes-clean.md %}) 8 | * [kubes compile]({% link _reference/kubes-compile.md %}) 9 | * [kubes completion]({% link _reference/kubes-completion.md %}) 10 | * [kubes completion_script]({% link _reference/kubes-completion_script.md %}) 11 | * [kubes delete]({% link _reference/kubes-delete.md %}) 12 | * [kubes deploy]({% link _reference/kubes-deploy.md %}) 13 | * [kubes describe]({% link _reference/kubes-describe.md %}) 14 | * [kubes docker]({% link _reference/kubes-docker.md %}) 15 | * [kubes exec]({% link _reference/kubes-exec.md %}) 16 | * [kubes get]({% link _reference/kubes-get.md %}) 17 | * [kubes init]({% link _reference/kubes-init.md %}) 18 | * [kubes logs]({% link _reference/kubes-logs.md %}) 19 | * [kubes new]({% link _reference/kubes-new.md %}) 20 | * [kubes prune]({% link _reference/kubes-prune.md %}) 21 | * [kubes version]({% link _reference/kubes-version.md %}) 22 | -------------------------------------------------------------------------------- /docs/search/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: Search 3 | search_omit: true 4 | --- 5 | 6 |
7 |

Search Tips:

8 |

To OR search terms: "install aws"

9 |

To AND search terms: "+install +aws"

10 |

To filter or reject search terms: "-aws"

11 |

More: Search Tips

12 |
13 | 14 | 15 |

16 | results found for: 17 |

18 |
19 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /docs/support.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Support 3 | --- 4 | 5 | ## Getting Help 6 | 7 | If you're looking for support for kubes, here are some options: 8 | 9 | * Read the [Documentation](http://https://kubes.guru) 10 | 11 | ## Report a bug 12 | 13 | If you think you've found a bug within the kubes repository, [open an issue](https://github.com/boltops-tools/kubes/issues/new/choose). 14 | 15 | Happy Hackin' 😁 16 | 17 | ## Commercial Support 18 | 19 | If you would like professional help, [BoltOps](https://www.boltops.com/) provides consulting. Feel free to reach out: [contact page](https://www.boltops.com/contact) 20 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/font-awesome/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /docs/vendor/font-awesome/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/font-awesome/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/vendor/font-awesome/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/font-awesome/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/vendor/font-awesome/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/font-awesome/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/vendor/font-awesome/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/font-awesome/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/animated.less: -------------------------------------------------------------------------------- 1 | // Animated Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .@{fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/bordered-pulled.less: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em @fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .@{fa-css-prefix}-pull-left { float: left; } 11 | .@{fa-css-prefix}-pull-right { float: right; } 12 | 13 | .@{fa-css-prefix} { 14 | &.@{fa-css-prefix}-pull-left { margin-right: .3em; } 15 | &.@{fa-css-prefix}-pull-right { margin-left: .3em; } 16 | } 17 | 18 | /* Deprecated as of 4.4.0 */ 19 | .pull-right { float: right; } 20 | .pull-left { float: left; } 21 | 22 | .@{fa-css-prefix} { 23 | &.pull-left { margin-right: .3em; } 24 | &.pull-right { margin-left: .3em; } 25 | } 26 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/@fa-line-height-base FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/font-awesome.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables.less"; 7 | @import "mixins.less"; 8 | @import "path.less"; 9 | @import "core.less"; 10 | @import "larger.less"; 11 | @import "fixed-width.less"; 12 | @import "list.less"; 13 | @import "bordered-pulled.less"; 14 | @import "animated.less"; 15 | @import "rotated-flipped.less"; 16 | @import "stacked.less"; 17 | @import "icons.less"; 18 | @import "screen-reader.less"; 19 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/larger.less: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .@{fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .@{fa-css-prefix}-2x { font-size: 2em; } 11 | .@{fa-css-prefix}-3x { font-size: 3em; } 12 | .@{fa-css-prefix}-4x { font-size: 4em; } 13 | .@{fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/list.less: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: @fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: (-@fa-li-width + (4em / 14)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'), 9 | url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'), 10 | url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'), 11 | url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/rotated-flipped.less: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-rotate-90 { .fa-icon-rotate(90deg, 1); } 5 | .@{fa-css-prefix}-rotate-180 { .fa-icon-rotate(180deg, 2); } 6 | .@{fa-css-prefix}-rotate-270 { .fa-icon-rotate(270deg, 3); } 7 | 8 | .@{fa-css-prefix}-flip-horizontal { .fa-icon-flip(-1, 1, 0); } 9 | .@{fa-css-prefix}-flip-vertical { .fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .@{fa-css-prefix}-rotate-90, 15 | :root .@{fa-css-prefix}-rotate-180, 16 | :root .@{fa-css-prefix}-rotate-270, 17 | :root .@{fa-css-prefix}-flip-horizontal, 18 | :root .@{fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/screen-reader.less: -------------------------------------------------------------------------------- 1 | // Screen Readers 2 | // ------------------------- 3 | 4 | .sr-only { .sr-only(); } 5 | .sr-only-focusable { .sr-only-focusable(); } 6 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/less/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_animated.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .#{$fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_bordered-pulled.scss: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em $fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .#{$fa-css-prefix}-pull-left { float: left; } 11 | .#{$fa-css-prefix}-pull-right { float: right; } 12 | 13 | .#{$fa-css-prefix} { 14 | &.#{$fa-css-prefix}-pull-left { margin-right: .3em; } 15 | &.#{$fa-css-prefix}-pull-right { margin-left: .3em; } 16 | } 17 | 18 | /* Deprecated as of 4.4.0 */ 19 | .pull-right { float: right; } 20 | .pull-left { float: left; } 21 | 22 | .#{$fa-css-prefix} { 23 | &.pull-left { margin-right: .3em; } 24 | &.pull-right { margin-left: .3em; } 25 | } 26 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/#{$fa-line-height-base} FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_larger.scss: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .#{$fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .#{$fa-css-prefix}-2x { font-size: 2em; } 11 | .#{$fa-css-prefix}-3x { font-size: 3em; } 12 | .#{$fa-css-prefix}-4x { font-size: 4em; } 13 | .#{$fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), 9 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 10 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 11 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .#{$fa-css-prefix}-rotate-90, 15 | :root .#{$fa-css-prefix}-rotate-180, 16 | :root .#{$fa-css-prefix}-rotate-270, 17 | :root .#{$fa-css-prefix}-flip-horizontal, 18 | :root .#{$fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_screen-reader.scss: -------------------------------------------------------------------------------- 1 | // Screen Readers 2 | // ------------------------- 3 | 4 | .sr-only { @include sr-only(); } 5 | .sr-only-focusable { @include sr-only-focusable(); } 6 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/_stacked.scss: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .#{$fa-css-prefix}-stack-1x, .#{$fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .#{$fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .#{$fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .#{$fa-css-prefix}-inverse { color: $fa-inverse; } 21 | -------------------------------------------------------------------------------- /docs/vendor/font-awesome/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables"; 7 | @import "mixins"; 8 | @import "path"; 9 | @import "core"; 10 | @import "larger"; 11 | @import "fixed-width"; 12 | @import "list"; 13 | @import "bordered-pulled"; 14 | @import "animated"; 15 | @import "rotated-flipped"; 16 | @import "stacked"; 17 | @import "icons"; 18 | @import "screen-reader"; 19 | -------------------------------------------------------------------------------- /docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.eot -------------------------------------------------------------------------------- /docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.ttf -------------------------------------------------------------------------------- /docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.woff -------------------------------------------------------------------------------- /docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/docs/vendor/simple-line-icons/fonts/Simple-Line-Icons.woff2 -------------------------------------------------------------------------------- /exe/kubes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # Trap ^C 4 | Signal.trap("INT") { 5 | puts "\nCtrl-C detected. Exiting..." 6 | sleep 0.1 7 | exit 8 | } 9 | 10 | $:.unshift(File.expand_path("../../lib", __FILE__)) 11 | require "kubes" 12 | require "kubes/cli" 13 | 14 | Kubes::CLI.start(ARGV) 15 | -------------------------------------------------------------------------------- /lib/kubes.rb: -------------------------------------------------------------------------------- 1 | $stdout.sync = true unless ENV["KUBES_STDOUT_SYNC"] == "0" 2 | 3 | $:.unshift(File.expand_path("../", __FILE__)) 4 | 5 | require "kubes/autoloader" 6 | Kubes::Autoloader.setup 7 | 8 | require "active_support" 9 | require "active_support/core_ext/class" 10 | require "active_support/core_ext/hash" 11 | require "active_support/core_ext/string" 12 | require "active_support/ordered_options" 13 | require "deep_merge/rails_compat" 14 | require "dsl_evaluator" 15 | require "fileutils" 16 | require "hash_squeezer" 17 | require "kubes/version" 18 | require "memoist" 19 | require "rainbow/ext/string" 20 | require "singleton" 21 | require "yaml" 22 | 23 | # core helper libraries 24 | require "kubes_aws" 25 | require "kubes_google" 26 | 27 | DslEvaluator.backtrace_reject = "lib/kubes" 28 | 29 | module Kubes 30 | class Error < StandardError; end 31 | class MissingDockerImage < Error; end 32 | extend Core 33 | end 34 | 35 | Kubes::Booter.boot 36 | -------------------------------------------------------------------------------- /lib/kubes/args/custom.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Args 2 | class Custom 3 | extend Memoist 4 | include Dsl 5 | include DslEvaluator 6 | 7 | attr_accessor :name 8 | def initialize(name, file) 9 | @name = name.to_s 10 | @file = file # IE: .kubes/config/kubectl/args.rb 11 | @commands = {} 12 | end 13 | 14 | def build 15 | return @commands unless File.exist?(@file) 16 | evaluate_file(@file) 17 | @commands.deep_stringify_keys! 18 | end 19 | memoize :build 20 | 21 | def args 22 | args = dig("args") 23 | args.compact.flatten 24 | end 25 | 26 | def dig(prop, default=[]) 27 | @commands.dig(@name, prop) || default 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/kubes/args/dsl.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Args 2 | module Dsl 3 | def command(*commands, **props) 4 | commands.each do |name| 5 | each_command(name, props) 6 | end 7 | end 8 | alias_method :commands, :command 9 | 10 | def each_command(name, props={}) 11 | @commands[name.to_s] = props 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/auth.rb: -------------------------------------------------------------------------------- 1 | module Kubes 2 | class Auth 3 | def initialize(image) 4 | @image = image 5 | end 6 | 7 | def run 8 | klass = strategy_class 9 | return unless klass 10 | klass.new(@image).run 11 | end 12 | 13 | # Currently only support ECR and GCR 14 | # TODO: consider moving this to plugin gems 15 | def strategy_class 16 | return unless auth? 17 | case @image 18 | when /\.amazonaws\.com/ # IE: 112233445566.dkr.ecr.us-west-2.amazonaws.com/demo/sinatra 19 | Ecr 20 | when /gcr\.io/ 21 | Gcr 22 | end 23 | end 24 | 25 | def auth? 26 | if ENV['KUBES_REPO_AUTO_AUTH'].nil? 27 | Kubes.config.repo_auto_auth 28 | else 29 | %w[1 true].include?(ENV['KUBES_REPO_AUTO_AUTH']) 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /lib/kubes/auth/base.rb: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | class Kubes::Auth 4 | class Base 5 | include Kubes::Logging 6 | 7 | def initialize(image) 8 | @image = image 9 | @repo_domain = "#{image.split('/').first}" 10 | end 11 | 12 | def ensure_dotdocker_exists 13 | dirname = File.dirname(docker_config) 14 | FileUtils.mkdir_p(dirname) unless File.exist?(dirname) 15 | end 16 | 17 | def docker_config 18 | "#{ENV['HOME']}/.docker/config.json" 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/kubes/auth/gcr.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Auth 2 | class Gcr < Base 3 | def run 4 | authorize! unless authorized? 5 | end 6 | 7 | def authorize! 8 | command = "gcloud auth configure-docker" 9 | logger.debug "Authorizing GCR with: #{command}" 10 | success = system(command) 11 | unless success 12 | logger.error "ERROR: running #{command}".color(:red) 13 | exit $?.exitstatus if exit_on_fail 14 | end 15 | success 16 | end 17 | 18 | def authorized? 19 | return false unless File.exist?(docker_config) 20 | data = JSON.load(IO.read(docker_config)) 21 | !!data.dig('credHelpers', 'gcr.io') 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/kubes/autoloader.rb: -------------------------------------------------------------------------------- 1 | require "zeitwerk" 2 | 3 | module Kubes 4 | class Autoloader 5 | class Inflector < Zeitwerk::Inflector 6 | def camelize(basename, _abspath) 7 | map = { cli: "CLI", version: "VERSION" } 8 | map[basename.to_sym] || super 9 | end 10 | end 11 | 12 | class << self 13 | def setup 14 | loader = Zeitwerk::Loader.new 15 | loader.inflector = Inflector.new 16 | loader.push_dir(File.dirname(__dir__)) # lib 17 | 18 | helpers = "#{kubes_root}/.kubes/helpers" 19 | loader.push_dir(helpers) if File.exist?(helpers) # project helpers 20 | 21 | loader.setup 22 | end 23 | 24 | # Autoloader runs so early that Kubes.root is not available, so we must declare it here 25 | def kubes_root 26 | ENV['KUBES_ROOT'] || '.' 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/kubes/aws_services.rb: -------------------------------------------------------------------------------- 1 | require "aws-sdk-ecr" 2 | 3 | # require "aws_mfa_secure/ext/aws" # add MFA support 4 | 5 | module Kubes 6 | module AwsServices 7 | extend Memoist 8 | 9 | def ecr 10 | Aws::ECR::Client.new 11 | end 12 | memoize :ecr 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/booter.rb: -------------------------------------------------------------------------------- 1 | module Kubes 2 | module Booter 3 | def boot 4 | run_hooks 5 | end 6 | 7 | # Special boot hooks run super early, even before plugins are loaded. 8 | # Useful for setting env vars and other early things. 9 | # 10 | # config/boot.rb 11 | # config/boot/dev.rb 12 | # 13 | def run_hooks 14 | run_hook 15 | run_hook(Kubes.env) 16 | end 17 | 18 | def run_hook(env=nil) 19 | name = env ? "boot/#{env}" : "boot" 20 | path = "#{Kubes.root}/.kubes/#{name}.rb" 21 | require path if File.exist?(path) 22 | end 23 | 24 | extend self 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/kubes/cli/apply.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Apply < Base 3 | def run 4 | compile 5 | logger.info "Deploying kubes resources" 6 | Kubes::Kubectl::Dispatcher.new(:apply, @options).run 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/kubes/cli/base.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Base 3 | include Kubes::Logging 4 | 5 | def initialize(options={}) 6 | @options = options 7 | end 8 | 9 | def compile 10 | Compile.new(@options).run unless @options[:compile] == false 11 | end 12 | 13 | def pod_name 14 | return unless @options[:pod] 15 | 16 | pods = Kubes::Kubectl::Fetch::Pods.new(@options) 17 | items = pods.fetch(:pod) 18 | metas = items.map { |i| i['metadata'] } 19 | metas.select! { |i| i['name'].include?(@options[:pod]) } 20 | meta = metas.sort { i['creationTimestamp'] }.last 21 | meta['name'] if meta 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/kubes/cli/build.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Build < Base 3 | def run 4 | return unless build? 5 | Kubes::Docker.new(@options, "build").run 6 | Kubes::Docker.new(@options, "push").run 7 | end 8 | 9 | def build? 10 | return false if @options[:build] == false || @options[:image] || Kubes.config.image 11 | @options[:resource].nil? || @options[:resource] == "deployment" 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/cli/clean.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Clean < Base 3 | def run 4 | path = ".kubes/output" 5 | FileUtils.rm_rf("#{Kubes.root}/#{path}") 6 | logger.info "Removed #{path}" unless @options[:mute] 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/kubes/cli/compile.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Compile < Base 3 | # Separate command like prune can call compile. Apply also calls Prune. 4 | # Instead of moving Compile out of Prune, will use this class variable. 5 | # In case we have other cases where compile is called in another area. 6 | # We only want compiled to be called once so hooks only fire once. 7 | # Done here so we don't clean and remove the .kubes/output folder. 8 | @@compiled = false 9 | def run 10 | return if @@compiled 11 | build_docker_image 12 | Clean.new(@options.merge(mute: true)).run 13 | Kubes::Compiler.new(@options).run 14 | @@compiled = true 15 | end 16 | 17 | # auto build docker image and push image if kubes docker build not yet called 18 | def build_docker_image 19 | return if File.exist?(Kubes.config.state.path) 20 | Build.new(@options).run 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/kubes/cli/delete.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Delete < Base 3 | include Kubes::Util::Sure 4 | 5 | def run 6 | compile 7 | perform(preview: true) unless @options[:yes] 8 | sure?("This will delete resources. Are you sure?") 9 | perform(preview: false) 10 | end 11 | 12 | def perform(preview: false) 13 | Kubes::Kubectl::Dispatcher.new(:delete, @options.merge(preview: preview)).run 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/kubes/cli/deploy.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Deploy < Base 3 | def run 4 | Build.new(@options).run 5 | Apply.new(@options).run # also calls Compile 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/kubes/cli/describe.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Describe < Base 3 | def run 4 | compile 5 | Kubes::Kubectl.run(:describe, @options) 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/kubes/cli/docker.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Docker < Kubes::Command 3 | desc "build", "Build docker image." 4 | long_desc Help.text("docker:build") 5 | option :push, type: :boolean, default: false 6 | def build 7 | builder = Kubes::Docker.new(options, "build") 8 | builder.run 9 | push if options[:push] 10 | end 11 | 12 | desc "name", "Print the full docker image with tag that was last generated." 13 | long_desc Help.text("docker:name") 14 | option :name, type: :boolean, default: false 15 | def name 16 | builder = Kubes::Docker.new(options, "build") 17 | name = builder.read_image_name 18 | if name 19 | puts name 20 | else 21 | $stderr.puts(<<~EOL) 22 | WARN: docker image has not yet been built. Please first run: 23 | 24 | kubes docker build 25 | 26 | EOL 27 | end 28 | end 29 | 30 | desc "push", "Push the docker image." 31 | long_desc Help.text("docker:push") 32 | option :push, type: :boolean, default: false 33 | def push 34 | pusher = Kubes::Docker.new(options, "push") 35 | pusher.run 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/kubes/cli/get.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class Get < Base 3 | def run 4 | compile 5 | Kubes::Kubectl.run(:get, @options.merge(exit_on_fail: false)) 6 | return unless @options[:show_pods] 7 | pods = Kubes::Kubectl::Fetch::Pods.new(@options) 8 | pods.show 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/kubes/cli/help.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | module Help 3 | class << self 4 | def text(namespaced_command) 5 | path = namespaced_command.to_s.gsub(':','/') 6 | path = File.expand_path("../help/#{path}.md", __FILE__) 7 | IO.read(path) if File.exist?(path) 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/kubes/cli/help/completion.md: -------------------------------------------------------------------------------- 1 | ## Examples 2 | 3 | kubes completion 4 | 5 | Prints words for TAB auto-completion. 6 | 7 | kubes completion 8 | kubes completion hello 9 | kubes completion hello name 10 | 11 | To enable, TAB auto-completion add the following to your profile: 12 | 13 | eval $(kubes completion_script) 14 | 15 | Auto-completion example usage: 16 | 17 | kubes [TAB] 18 | kubes hello [TAB] 19 | kubes hello name [TAB] 20 | kubes hello name --[TAB] 21 | -------------------------------------------------------------------------------- /lib/kubes/cli/help/completion_script.md: -------------------------------------------------------------------------------- 1 | To use, add the following to your `~/.bashrc` or `~/.profile` 2 | 3 | eval $(kubes completion_script) 4 | -------------------------------------------------------------------------------- /lib/kubes/cli/help/deploy.md: -------------------------------------------------------------------------------- 1 | ## Examples 2 | 3 | Deploy all resources in .kubes/resources/web 4 | 5 | kubes deploy web 6 | 7 | Deploy specific resource, like .kubes/resources/web/deployment.rb 8 | 9 | kubes deploy web deployment 10 | kubes deploy web service 11 | -------------------------------------------------------------------------------- /lib/kubes/cli/help/new/helper.md: -------------------------------------------------------------------------------- 1 | ## Examples 2 | 3 | $ kubes new helper custom 4 | create .kubes/helpers/custom_helper.rb 5 | -------------------------------------------------------------------------------- /lib/kubes/cli/help/new/hook.md: -------------------------------------------------------------------------------- 1 | ## Examples 2 | 3 | $ kubes new hook docker 4 | create .kubes/config/hooks/docker.rb 5 | $ kubes new hook kubectl 6 | create .kubes/config/hooks/kubectl.rb 7 | $ kubes new hook kubes 8 | create .kubes/config/hooks/kubes.rb 9 | $ -------------------------------------------------------------------------------- /lib/kubes/cli/help/new/resource.md: -------------------------------------------------------------------------------- 1 | ## Examples 2 | 3 | $ kubes new resource ingress 4 | create .kubes/resources/web/ingress.yaml 5 | $ kubes new resource service_account 6 | create .kubes/resources/shared/service_account.yaml 7 | $ 8 | 9 | ## Supported Resources 10 | 11 | Here's a list of some of the supported resources. 12 | 13 | backend_config 14 | config_map 15 | daemon_set 16 | deployment 17 | ingress 18 | job 19 | managed_certificate 20 | namespace 21 | network_policy 22 | pod 23 | role_binding 24 | role 25 | secret 26 | service_account 27 | service 28 | 29 | Refer to the source code to all the resources that the generator supports: 30 | https://github.com/boltops-tools/kubes/blob/master/lib/templates/new/resource/yaml 31 | -------------------------------------------------------------------------------- /lib/kubes/cli/help/new/variable.md: -------------------------------------------------------------------------------- 1 | ## Examples 2 | 3 | $ kubes new variable 4 | create .kubes/variables/dev.rb 5 | $ KUBES_ENV=prod kubes new variable 6 | create .kubes/variables/prod.rb 7 | -------------------------------------------------------------------------------- /lib/kubes/cli/new.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI 2 | class New < Kubes::Command 3 | long_desc Help.text("new/resource") 4 | Resource.options.each { |args| option(*args) } 5 | register(Resource, "resource", "resource", "Generates Kubes Kubernetes resource definition.") 6 | 7 | long_desc Help.text("new/helper") 8 | Helper.options.each { |args| option(*args) } 9 | register(Helper, "helper", "helper", "Generates kubes helper file.") 10 | 11 | long_desc Help.text("new/variable") 12 | Variable.options.each { |args| option(*args) } 13 | register(Variable, "variable", "variable", "Generates kubes variable file.") 14 | 15 | long_desc Help.text("new/hook") 16 | Hook.options.each { |args| option(*args) } 17 | register(Hook, "hook", "hook", "Generates kubes hook file.") 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/kubes/cli/new/helper.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI::New 2 | class Helper < Kubes::CLI::Sequence 3 | argument :name, default: "custom" 4 | 5 | def self.options 6 | [ 7 | [:force, aliases: ["y"], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"], 8 | ] 9 | end 10 | options.each { |args| class_option(*args) } 11 | 12 | private 13 | def underscored_name 14 | name.include?("_helper") ? name : "#{name}_helper" 15 | end 16 | 17 | public 18 | def create_helper 19 | set_source("new/helper") 20 | file = "#{underscored_name}.rb" 21 | template "file.rb", ".kubes/helpers/#{file}" 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/kubes/cli/new/hook.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI::New 2 | class Hook < Kubes::CLI::Sequence 3 | argument :type, default: "kubes", description: "IE: docker, kubectl, kubes" # description doesnt really show up 4 | 5 | def self.options 6 | [ 7 | [:force, aliases: ["y"], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"], 8 | ] 9 | end 10 | options.each { |args| class_option(*args) } 11 | 12 | public 13 | def create_hook 14 | set_source("new/hooks") 15 | template "#{type}.rb", ".kubes/config/hooks/#{type}.rb" 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/kubes/cli/new/variable.rb: -------------------------------------------------------------------------------- 1 | class Kubes::CLI::New 2 | class Variable < Kubes::CLI::Sequence 3 | def self.options 4 | [ 5 | [:force, aliases: ["y"], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"], 6 | ] 7 | end 8 | options.each { |args| class_option(*args) } 9 | 10 | def create_helper 11 | set_source("new/variable") 12 | file = "#{Kubes.env}.rb" 13 | template "file.rb", ".kubes/variables/#{file}" 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/kubes/cli/sequence.rb: -------------------------------------------------------------------------------- 1 | require 'thor' 2 | 3 | class Kubes::CLI 4 | class Sequence < Thor::Group 5 | include Thor::Actions 6 | include Kubes::Logging 7 | 8 | private 9 | def logger 10 | Kubes.logger 11 | end 12 | 13 | def set_source(type) 14 | override_source_paths(File.expand_path("../../templates/#{type}", __dir__)) 15 | end 16 | 17 | def override_source_paths(*paths) 18 | # https://github.com/erikhuda/thor/blob/34df888d721ecaa8cf0cea97d51dc6c388002742/lib/thor/actions.rb#L128 19 | instance_variable_set(:@source_paths, nil) # unset instance variable cache 20 | # Using string with instance_eval because block doesnt have access to path at runtime. 21 | self.class.instance_eval %{ 22 | def self.source_paths 23 | #{paths.flatten.inspect} 24 | end 25 | } 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/kubes/compiler/decorator/base.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Decorator 2 | class Base 3 | attr_reader :data 4 | def initialize(data) 5 | @data = data 6 | end 7 | 8 | def run 9 | return @data unless Kubes.config.suffix_hash 10 | process 11 | end 12 | 13 | def result 14 | if @data.key?(Kubes::Compiler::Dsl::Core::Blocks) 15 | @data.results.each { |k,v| run(v) } # returns nil 16 | else 17 | run # processes and returns @data 18 | end 19 | @data # important to return @data so we keep the original @data structure: Blocks or Hash 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/kubes/compiler/decorator/hashable.rb: -------------------------------------------------------------------------------- 1 | require 'digest' 2 | 3 | module Kubes::Compiler::Decorator 4 | class Hashable < Base 5 | include Kubes::Compiler::Util::YamlDump 6 | 7 | def store 8 | # even though name is required, will allow logic to get the kubectl apply and kubectl to surface the required name error 9 | name = @data.dig('metadata','name') 10 | return @data unless name 11 | 12 | # scope Kind so Secret and ConfigMap can have same name 13 | md5 = md5(@data) 14 | @data['metadata']['name'] = "#{name}-#{md5}" 15 | Storage.store(@data['kind'], name, md5) 16 | @data 17 | end 18 | 19 | def md5(data) 20 | content = yaml_dump(data) 21 | Digest::MD5.hexdigest(content)[0..9] 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/kubes/compiler/decorator/hashable/storage.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Compiler::Decorator::Hashable 2 | module Storage 3 | @@md5s = {} 4 | def store(kind, name, md5) 5 | @@md5s[kind] ||= {} 6 | @@md5s[kind][name] = md5 7 | end 8 | 9 | def fetch(kind, name) 10 | @@md5s[kind] ||= {} 11 | @@md5s[kind][name] 12 | end 13 | 14 | def md5s 15 | @@md5s 16 | end 17 | extend self 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/kubes/compiler/decorator/pre.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Decorator 2 | class Pre < Base 3 | def process 4 | case @data['kind'] 5 | when "ConfigMap", "Secret" 6 | Hashable.new(@data).store 7 | else 8 | @data # passthrough 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/core/base.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Core 2 | class Base 3 | extend Fields 4 | include DslEvaluator 5 | include Helpers 6 | include Kubes::Compiler::Shared::RuntimeHelpers 7 | 8 | def initialize(options={}) 9 | @options = options 10 | @name = options[:name] 11 | @path = options[:path] 12 | load_runtime_helpers 13 | end 14 | 15 | def run 16 | evaluate_file(@path) # main resource definition 17 | result 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/core/files.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Core 2 | module Files 3 | def files(*list) 4 | dir = current_dir 5 | list.each do |file| 6 | path = "#{dir}/#{file}" 7 | load_data_from_file(path) 8 | end 9 | end 10 | 11 | def load_data_from_file(path) 12 | parser = Kubes::Compiler::Dsl::Core::Parser.new(path) 13 | items = parser.parse 14 | items.transform_values! { |v| base64(v) } if secret_class? 15 | data(items) 16 | end 17 | 18 | def secret_class? 19 | self.class == Kubes::Compiler::Dsl::Syntax::Secret 20 | end 21 | 22 | def current_dir 23 | resources_line = caller.find { |l| l.include?('.kubes/resources') } 24 | path = resources_line.split(':').first 25 | File.dirname(path) # IE: /full/path/.kubes/resources 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/core/helpers.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Core 2 | module Helpers 3 | def dockerfile_port 4 | path = "#{Kubes.root}/Dockerfile" 5 | File.exist?(path) ? parse_for_dockerfile_port(path) : 80 6 | end 7 | 8 | private 9 | def parse_for_dockerfile_port(path) 10 | lines = IO.read(path).split("\n") 11 | expose_line = lines.find { |l| l =~ /^EXPOSE / } 12 | if expose_line 13 | md = expose_line.match(/EXPOSE (\d+)/) 14 | port = md[1] if md 15 | end 16 | port ? port.to_i : 80 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/backend_config.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class BackendConfig < Resource 3 | fields :domain, 4 | :domains 5 | 6 | def default_apiVersion 7 | "cloud.google.com/v1" 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/cluster_role.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class ClusterRole < Role 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/cluster_role_binding.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class ClusterRoleBinding < RoleBinding 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/config_map.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class ConfigMap < Resource 3 | include Kubes::Compiler::Dsl::Core::Files 4 | 5 | # kubectl explain secret 6 | fields "data:hash", # 7 | "binaryData:hash" # 8 | 9 | def default_apiVersion 10 | "v1" 11 | end 12 | 13 | def default_result_append 14 | { 15 | data: data, 16 | binaryData: binaryData, 17 | } 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/daemon_set.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class DaemonSet < Resource 3 | fields :minReadySeconds, # 4 | :revisionHistoryLimit, # 5 | :selector, # -required- 6 | :template, # -required- 7 | :updateStrategy # 8 | 9 | def default_apiVersion 10 | "apps/v1" 11 | end 12 | 13 | def default_spec 14 | { 15 | minReadySeconds: minReadySeconds, 16 | revisionHistoryLimit: revisionHistoryLimit, 17 | selector: selector, 18 | template: template, 19 | updateStrategy: updateStrategy, 20 | } 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/endpoint.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class Endpoint < Resource 3 | fields :subsets 4 | 5 | # kubectl explain endpoints.subsets 6 | fields :addresses, # <[]Object> 7 | :notReadyAddresses, # <[]Object> 8 | :ports # <[]Object> 9 | 10 | def default_kind 11 | return @kind_from_block if @kind_from_block 12 | "Endpoints" # always plural 13 | end 14 | 15 | def default_apiVersion 16 | "v1" 17 | end 18 | 19 | def default_top 20 | top = super 21 | top.merge( 22 | subsets: subsets 23 | ) 24 | end 25 | 26 | def default_subsets 27 | [{ 28 | addresses: addresses, 29 | notReadyAddresses: notReadyAddresses, 30 | ports: ports, 31 | }] 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/ingress.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class Ingress < Resource 3 | # kubectl explain ingress.spec 4 | fields :backend, # 5 | :rules, # <[]Object> 6 | :tls # <[]Object> 7 | 8 | # kubectl explain ingress.spec.rules.http 9 | fields :paths # <[]Object> -required- 10 | 11 | # kubectl explain ingress.spec.rules.http.paths.backend 12 | fields :serviceName, # -required- 13 | :servicePort # -required- 14 | 15 | def default_apiVersion 16 | "networking.k8s.io/v1beta1" 17 | end 18 | 19 | def default_spec 20 | { rules: rules } 21 | end 22 | 23 | def default_rules 24 | [ 25 | http: { 26 | paths: paths 27 | } 28 | ] 29 | end 30 | 31 | def default_paths 32 | [ 33 | path: '/*', 34 | backend: { 35 | serviceName: serviceName, 36 | servicePort: servicePort, 37 | } 38 | ] 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/managed_certificate.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class ManagedCertificate < Resource 3 | fields :domain, 4 | :domains 5 | 6 | def default_apiVersion 7 | "networking.gke.io/v1beta2" 8 | end 9 | 10 | def default_spec 11 | { domains: domains } 12 | end 13 | 14 | def default_domains 15 | [domain] 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/namespace.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class Namespace < Resource 3 | # override 4 | def default_metadata 5 | { 6 | annotations: annotations, 7 | name: name, 8 | labels: labels, 9 | # no namespace 10 | } 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/role.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class Role < Resource 3 | fields :rules # <[]Object> 4 | 5 | # kubectl explain role.rules 6 | fields :apiGroups, # <[]string> 7 | :nonResourceURLs, # <[]string> 8 | :resourceNames, # <[]string> 9 | :resources, # <[]string> 10 | :verbs # <[]string> -required- 11 | 12 | def apiVersion 13 | "rbac.authorization.k8s.io/v1" 14 | end 15 | 16 | # override superclass method - no spec 17 | def default_top 18 | { 19 | apiVersion: apiVersion, 20 | kind: kind, 21 | metadata: metadata, 22 | rules: rules, 23 | } 24 | end 25 | 26 | def default_rules 27 | [default_rule] 28 | end 29 | 30 | def default_rule 31 | { 32 | apiGroups: apiGroups, 33 | nonResourceURLs: nonResourceURLs, 34 | resourceNames: resourceNames, 35 | resources: resources, 36 | verbs: verbs, 37 | } 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/role_binding.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class RoleBinding < Resource 3 | # kubectl explain rolebinding 4 | fields :roleRef, # -required- 5 | :subjects # <[]Object> 6 | 7 | # kubectl explain rolebinding.roleRef 8 | fields :apiGroup, # -required- 9 | :roleKind, # -required- originally kind 10 | :roleName # -required- originally name 11 | 12 | def apiVersion 13 | "rbac.authorization.k8s.io/v1" 14 | end 15 | 16 | # override superclass method - no spec 17 | def default_top 18 | { 19 | apiVersion: apiVersion, 20 | kind: kind, 21 | metadata: metadata, 22 | roleRef: roleRef, 23 | subjects: subjects, 24 | } 25 | end 26 | 27 | def default_roleRef 28 | { 29 | apiGroup: apiGroup, 30 | kind: roleKind, 31 | name: roleName, 32 | } 33 | end 34 | 35 | def default_roleKind 36 | "Role" 37 | end 38 | 39 | def default_apiGroup 40 | "rbac.authorization.k8s.io" 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/secret.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class Secret < Resource 3 | include Kubes::Compiler::Dsl::Core::Files 4 | 5 | # kubectl explain secret 6 | fields "data:hash", # 7 | "stringData:hash", # 8 | :type # 9 | 10 | def default_apiVersion 11 | "v1" 12 | end 13 | 14 | def default_result_append 15 | { 16 | data: data, 17 | stringData: stringData, 18 | type: type, 19 | } 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/kubes/compiler/dsl/syntax/service_account.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Dsl::Syntax 2 | class ServiceAccount < Resource 3 | # kubectl explain serviceaccount 4 | fields :automountServiceAccountToken, # 5 | :imagePullSecrets, # <[]Object> 6 | :secrets # <[]Object> 7 | 8 | # override superclass method - no spec 9 | def default_top 10 | { 11 | apiVersion: apiVersion, 12 | kind: kind, 13 | metadata: metadata, 14 | automountServiceAccountToken: automountServiceAccountToken, 15 | imagePullSecrets: imagePullSecrets, 16 | secrets: secrets, 17 | } 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/kubes/compiler/shared/helpers.rb: -------------------------------------------------------------------------------- 1 | require "base64" 2 | require "json" 3 | 4 | module Kubes::Compiler::Shared 5 | module Helpers 6 | extend Kubes::Compiler::Dsl::Core::Fields 7 | fields "name" 8 | 9 | include ConfigMapHelper 10 | include DockerHelper 11 | include ExtraHelper 12 | include SecretHelper 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/compiler/shared/helpers/docker_helper.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Shared::Helpers 2 | module DockerHelper 3 | def docker_image 4 | return @options[:image] if @options[:image] # override 5 | return Kubes.config.image if Kubes.config.image 6 | built_image_helper 7 | end 8 | 9 | def built_image 10 | Deprecated.new.built_image 11 | built_image_helper 12 | end 13 | 14 | def built_image_helper 15 | path = Kubes.config.state.path 16 | unless File.exist?(path) 17 | raise Kubes::MissingDockerImage.new("Missing file with docker image built by kubes: #{path}. Try first running: kubes docker build") 18 | end 19 | data = JSON.load(IO.read(path)) 20 | data['image'] 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/kubes/compiler/shared/helpers/extra_helper.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Shared::Helpers 2 | module ExtraHelper 3 | def with_extra(value) 4 | [value, extra].compact.join('-') 5 | end 6 | 7 | def extra 8 | extra = ENV['KUBES_EXTRA'] 9 | extra&.strip&.empty? ? nil : extra # if blank string then also return nil 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/kubes/compiler/strategy.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Compiler 2 | class Strategy 3 | def initialize(options={}) 4 | @options = options 5 | @path = options[:path] 6 | end 7 | 8 | def compile 9 | result = Dispatcher.new(@options.merge(path: @path)).dispatch 10 | result.decorate!(:pre) # compile pre phase decoration 11 | result 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/compiler/strategy/base.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Compiler::Strategy 2 | class Base 3 | include Kubes::Compiler::Layering 4 | include Kubes::Compiler::Util::Normalize 5 | include Kubes::Compiler::Util::SaveFile 6 | include Kubes::Logging 7 | include Kubes::Util::Pretty 8 | 9 | def initialize(options={}) 10 | @options = options 11 | @path = options[:path] 12 | @save_file = save_file(@path) 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/kubes/compiler/strategy/erb/comment.rb: -------------------------------------------------------------------------------- 1 | # Processes the ERB files and looks for comments like 2 | # 3 | # #ERB if @testvar 4 | # - "some yaml" 5 | # #ERB end 6 | # 7 | class Kubes::Compiler::Strategy::Erb 8 | class Comment 9 | extend Memoist 10 | 11 | def initialize(path) 12 | @path = path 13 | end 14 | 15 | def lines 16 | IO.readlines(@path) 17 | end 18 | memoize :lines 19 | 20 | def process? 21 | !!lines.detect { |l| l.include?('#ERB') } 22 | end 23 | 24 | def process 25 | new_lines = lines.map do |line| 26 | md = line.match(/(.*)#ERB(.*)/) 27 | if md 28 | "#{md[1]}<%#{md[2]} %>\n" 29 | else 30 | line 31 | end 32 | end 33 | content = new_lines.join('') 34 | IO.write(erb_path, content) 35 | erb_path 36 | end 37 | 38 | def clean 39 | FileUtils.rm_f(erb_path) unless ENV['KUBES_KEEP_ERB'] 40 | end 41 | 42 | def erb_path 43 | "#{@path}.erb" 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/kubes/compiler/strategy/pass.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Compiler::Strategy 2 | class Pass < Base 3 | def run 4 | # use filehandle instead of content. write is aware of this and handles properly 5 | io = File.read(@path) 6 | Result.new(@save_file, io) 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/kubes/compiler/strategy/result.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Compiler::Strategy 2 | class Result 3 | include Kubes::Compiler::Util::YamlDump 4 | 5 | attr_reader :filename 6 | def initialize(filename, data) 7 | @filename, @data = filename, data 8 | end 9 | 10 | def io? 11 | @data.respond_to?(:read) 12 | end 13 | 14 | # decorate(:pre) or decorate(:post) 15 | def decorate!(phase) 16 | klass = "Kubes::Compiler::Decorator::#{phase.to_s.camelize}".constantize 17 | results = [@data].flatten 18 | results.map! do |r| 19 | klass.new(r).result 20 | end 21 | end 22 | 23 | def content 24 | data = filter_skip(@data) 25 | data.each { |item| item.delete('kubes') } 26 | return if data.empty? 27 | result = data.size == 1 ? data.first : data 28 | yaml_dump(result) 29 | end 30 | 31 | def skip? 32 | content.nil? 33 | end 34 | 35 | def filter_skip(data) 36 | data.reject do |item| 37 | item.dig('kubes', 'skip') 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/kubes/compiler/util/normalize.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Util 2 | module Normalize 3 | def normalize_kind(path) 4 | extract_type(path).underscore.camelize # Deployment, Service, Ingress, ManagedCertificate, etc 5 | end 6 | 7 | # info: web/service.yaml 8 | def extract_type(info) 9 | info = info.sub(%r{.*/.kubes/resources/}, '') 10 | _, kind = info.split('/') 11 | kind.sub('.yaml','').sub('.yml','').sub('.rb','').sub(/-.*/,'') 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/compiler/util/save_file.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Compiler::Util 2 | module SaveFile 3 | def save_file(path) 4 | filename = path.sub(%r{.*\.kubes/resources/},'') # IE: web/deployment.rb or web/deployment.yaml 5 | filename.sub('.yml','.yaml').sub('.rb','.yaml') 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/kubes/compiler/util/yaml_dump.rb: -------------------------------------------------------------------------------- 1 | require "json" 2 | require "yaml" 3 | 4 | module Kubes::Compiler::Util 5 | module YamlDump 6 | def yaml_dump(data) 7 | case data 8 | when Array 9 | items = data.map do |i| 10 | standardize_yaml(i) 11 | end 12 | items.map(&:to_yaml).join("") 13 | else # single resource in YAML 14 | data = standardize_yaml(data) 15 | data.to_yaml 16 | end 17 | end 18 | 19 | # https://stackoverflow.com/questions/24508364/how-to-emit-yaml-in-ruby-expanding-aliases/46104244#46104244 20 | # Prevents YAML from generating aliases/anchors. 21 | def standardize_yaml(data) 22 | json = data.to_json 23 | YAML.load(json) 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/kubes/completer/script.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Completer::Script 2 | def self.generate 3 | bash_script = File.expand_path("script.sh", File.dirname(__FILE__)) 4 | puts "source #{bash_script}" 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/kubes/completer/script.sh: -------------------------------------------------------------------------------- 1 | _kubes() { 2 | COMPREPLY=() 3 | local word="${COMP_WORDS[COMP_CWORD]}" 4 | local words=("${COMP_WORDS[@]}") 5 | unset words[0] 6 | local completion=$(kubes completion ${words[@]}) 7 | COMPREPLY=( $(compgen -W "$completion" -- "$word") ) 8 | } 9 | 10 | complete -F _kubes kubes 11 | -------------------------------------------------------------------------------- /lib/kubes/docker.rb: -------------------------------------------------------------------------------- 1 | module Kubes 2 | class Docker 3 | def initialize(options, name) 4 | @options = options 5 | @name = name 6 | end 7 | 8 | def run 9 | strategy = strategy_class.new(@options, @name) # @name: docker or push 10 | strategy.run 11 | end 12 | 13 | def strategy_class 14 | strategy = Kubes.config.builder.to_s.camelize # IE: Docker or Gcloud 15 | klass_name = "Kubes::Docker::Strategy::#{@name.camelize}::#{strategy}" 16 | klass_name.constantize 17 | end 18 | 19 | # For `kubes docker image` and read_image_name method 20 | include Kubes::Docker::Strategy::ImageName 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/kubes/docker/args/default.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Args 2 | class Default 3 | def initialize(name, image_name, options={}) 4 | @name, @image_name, @options = name.to_s, image_name, options 5 | @dockerfile = "Dockerfile" 6 | end 7 | 8 | def args 9 | case @name 10 | when "build" 11 | build_args 12 | when "push" 13 | [@image_name] 14 | else 15 | [] 16 | end 17 | end 18 | 19 | def build_args 20 | ["-t #{@image_name} -f #{@dockerfile} ."] 21 | end 22 | 23 | 24 | private 25 | def resource_path 26 | [".kubes/output", @options[:role], resource].compact.join('/') 27 | end 28 | 29 | def resource 30 | return unless r = @options[:resource] # intentional assignment 31 | r.include?(".yaml") ? r : "#{r}.yaml" 32 | end 33 | 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/kubes/docker/strategy/build/base.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Strategy::Build 2 | class Base 3 | extend Memoist 4 | include Kubes::Docker::Strategy::Utils 5 | 6 | def initialize(options, name) 7 | @options, @name = options, name 8 | end 9 | 10 | def run 11 | reserve_image_name 12 | check_dockerfile! 13 | perform 14 | store_image_name 15 | end 16 | 17 | def check_dockerfile! 18 | # Dockerfile is also used in args/default.rb, will have to combine if Dockerfile is made configurable 19 | return if File.exist?("Dockerfile") 20 | logger.error "ERROR: The Dockerfile does not exist. Cannot build the docker image without a Dockerfile".color(:red) 21 | exit 1 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/kubes/docker/strategy/build/docker.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Strategy::Build 2 | class Docker < Base 3 | def perform 4 | params = args.flatten.join(' ') 5 | command = "docker build #{params}" 6 | run_hooks("docker.rb", name: "build") do 7 | sh(command) 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/kubes/docker/strategy/build/gcloud.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Strategy::Build 2 | class Gcloud < Base 3 | def perform 4 | command = "gcloud builds submit --tag #{@@image_name}" 5 | run_hooks("docker.rb", name: "build") do 6 | sh(command) 7 | end 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/kubes/docker/strategy/push/base.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Strategy::Push 2 | class Base 3 | include Kubes::Docker::Strategy::Utils 4 | 5 | def initialize(options, name) 6 | @options, @name = options, name 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/kubes/docker/strategy/push/docker.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Strategy::Push 2 | class Docker < Base 3 | def run 4 | update_auth_token 5 | start_time = Time.now 6 | message = "Pushed #{image_name} docker image." 7 | if @options[:noop] 8 | message = "NOOP #{message}" 9 | else 10 | push 11 | end 12 | took = Time.now - start_time 13 | message << "\nDocker push took #{pretty_time(took)}.".color(:green) 14 | logger.info message 15 | end 16 | 17 | def push 18 | params = args.flatten.join(' ') 19 | command = "docker push #{params}" 20 | run_hooks("docker.rb", name: "push") do 21 | sh(command) 22 | end 23 | end 24 | 25 | def update_auth_token 26 | auth = Kubes::Auth.new(image_name) 27 | auth.run 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/kubes/docker/strategy/push/gcloud.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Strategy::Push 2 | class Gcloud < Base 3 | def run 4 | run_hooks("docker.rb", name: "push") do 5 | # noop, gcloud builds submit already pushes the image 6 | end 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/kubes/docker/strategy/utils.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Docker::Strategy 2 | module Utils 3 | include Kubes::Logging 4 | include Kubes::Util::Sh 5 | include Kubes::Util::Time 6 | include Kubes::Docker::Strategy::ImageName 7 | include Kubes::Hooks::Concern 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/kubes/hooks/concern.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Hooks 2 | module Concern 3 | # options example: {:name=>"apply", :file=>".kubes/output/web/service.yaml"} 4 | def run_hooks(file, options={}, &block) 5 | hooks = Kubes::Hooks::Builder.new(file, options) 6 | hooks.build # build hooks 7 | hooks.run_hooks(&block) 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/kubes/hooks/dsl.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Hooks 2 | module Dsl 3 | def before(*commands, **props) 4 | commands.each do |name| 5 | each_hook(:before, name, props) 6 | end 7 | end 8 | 9 | def after(*commands, **props) 10 | commands.each do |name| 11 | each_hook(:after, name, props) 12 | end 13 | end 14 | 15 | def each_hook(type, name, props={}) 16 | @hooks[type][name] ||= [] 17 | @hooks[type][name] << props 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/kubes/hooks/runner.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Hooks 2 | class Runner 3 | include Kubes::Util::Sh 4 | include Kubes::Logging 5 | 6 | def initialize(hook) 7 | @hook = hook 8 | @execute = @hook["execute"] 9 | end 10 | 11 | def run 12 | case @execute 13 | when String 14 | sh(@execute, exit_on_fail: @hook["exit_on_fail"]) 15 | when -> (e) { e.respond_to?(:public_instance_methods) && e.public_instance_methods.include?(:call) } 16 | @execute.new.call 17 | else 18 | @execute.call 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/kubes/kubectl/args/base.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Kubectl::Args 2 | class Base 3 | def initialize(name, options={}) 4 | @name, @options = name.to_s, options 5 | end 6 | 7 | def args 8 | meth = "#{@name}_args" # IE: apply_args 9 | send(meth) 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/kubes/kubectl/args/kustomize.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Kubectl::Args 2 | class Kustomize < Base 3 | def apply_args 4 | args = ["-k"] 5 | args << resource_path 6 | args 7 | end 8 | alias_method :delete_args, :apply_args 9 | 10 | def get_args 11 | args = ["-k"] 12 | args << resource_path 13 | args += ["-o #{@options[:output]}"] if @options[:output] 14 | args 15 | end 16 | alias_method :describe_args, :get_args 17 | 18 | private 19 | def resource_path 20 | [".kubes/output", @options[:role], resource].compact.join('/') 21 | end 22 | 23 | def resource 24 | return unless r = @options[:resource] # intentional assignment 25 | r.include?(".yaml") ? r : "#{r}.yaml" 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/kubes/kubectl/args/standard.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Kubectl::Args 2 | class Standard < Base 3 | def apply_args 4 | args = ["-f"] 5 | args << resource_path 6 | args 7 | end 8 | alias_method :delete_args, :apply_args 9 | 10 | def get_args 11 | args = ["--recursive -f"] 12 | args << resource_path 13 | args += ["-o #{@options[:output]}"] if @options[:output] 14 | args 15 | end 16 | alias_method :describe_args, :get_args 17 | 18 | private 19 | def resource_path 20 | if @options[:file] # batch: apply and delete 21 | @options[:file] 22 | else # get 23 | [".kubes/output", @options[:role], resource].compact.join('/') 24 | end 25 | end 26 | 27 | def resource 28 | return unless r = @options[:resource] # intentional assignment 29 | r.include?(".yaml") ? r : "#{r}.yaml" 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/kubes/kubectl/dispatcher.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Kubectl 2 | class Dispatcher 3 | def initialize(name, options={}) 4 | @name, @options = name.to_s, options 5 | end 6 | 7 | def run 8 | if Kubes.kustomize? 9 | Kubes::Kubectl.run(@name, @options) 10 | else 11 | Kubes::Kubectl::Batch.new(@name, @options).run 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/kubes/kubectl/fetch/base.rb: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | module Kubes::Kubectl::Fetch 4 | class Base 5 | extend Memoist 6 | include Kubes::Logging 7 | include Kubes::Util::Sh 8 | 9 | def initialize(options={}) 10 | @options = options 11 | end 12 | 13 | def fetch(kind) 14 | return [] unless namespace 15 | data = Kubes::Kubectl.capture("get #{kind} -o json -n #{namespace}") 16 | data['items'] || [] # Note: When fetching only 1 resource, items is not part of structure 17 | end 18 | 19 | def namespace 20 | path = ".kubes/output/shared/namespace.yaml" 21 | return unless File.exist?(path) 22 | data = Kubes::Kubectl.capture("get -f #{path} -o json") 23 | data['metadata']['name'] 24 | end 25 | memoize :namespace 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/kubes/kubectl/fetch/pods.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Kubectl::Fetch 2 | class Pods < Base 3 | extend Memoist 4 | 5 | def show 6 | return unless namespace 7 | sh("kubectl get pod -n #{namespace}") 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/kubes/kubectl/kustomize.rb: -------------------------------------------------------------------------------- 1 | class Kubes::Kubectl 2 | class Kustomize 3 | class << self 4 | extend Memoist 5 | 6 | def detect? 7 | expr = "#{Kubes.root}/.kubes/resources/**/*" 8 | !!Dir.glob(expr).detect { |p| p.include?("kustomization.y") } # allow for both .yml and .yaml to work 9 | end 10 | memoize :detect? 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/kubes/logger.rb: -------------------------------------------------------------------------------- 1 | require 'logger' 2 | 3 | module Kubes 4 | class Logger < ::Logger 5 | # Only need to override the add method as the other calls all lead to it. 6 | def add(severity, message = nil, progname = nil) 7 | # Taken from Logger#add source 8 | # https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add 9 | if message.nil? 10 | if block_given? 11 | message = yield 12 | else 13 | message = progname 14 | progname = @progname 15 | end 16 | end 17 | 18 | super # original logic 19 | end 20 | 21 | # plain formatting 22 | def format_message(severity, timestamp, progname, msg) 23 | "#{msg}\n" 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/kubes/logging.rb: -------------------------------------------------------------------------------- 1 | module Kubes 2 | module Logging 3 | def logger 4 | Kubes.logger 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/kubes/plugin.rb: -------------------------------------------------------------------------------- 1 | module Kubes 2 | module Plugin 3 | @@plugins = [] 4 | def plugins 5 | @@plugins 6 | end 7 | 8 | def register(klass) 9 | @@plugins << klass 10 | end 11 | 12 | extend self 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/util/consider.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Util 2 | module Consider 3 | def consider?(path) 4 | File.file?(path) && 5 | !path.include?('/resources/base') && 6 | !path.include?('/base.') && 7 | !path.include?('/all.') 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/kubes/util/pretty.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Util 2 | module Pretty 3 | def pretty_path(path) 4 | path.sub("#{Kubes.root}/",'') 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/kubes/util/sure.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Util 2 | module Sure 3 | def sure?(message="Are you sure?") 4 | if @options[:yes] 5 | sure = 'y' 6 | else 7 | print "#{message} (y/N) " 8 | sure = $stdin.gets 9 | end 10 | 11 | unless sure =~ /^y/ 12 | puts "Whew! Exiting." 13 | exit 0 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/kubes/util/time.rb: -------------------------------------------------------------------------------- 1 | module Kubes::Util 2 | module Time 3 | # http://stackoverflow.com/questions/4175733/convert-duration-to-hoursminutesseconds-or-similar-in-rails-3-or-ruby 4 | def pretty_time(total_seconds) 5 | minutes = (total_seconds / 60) % 60 6 | seconds = total_seconds % 60 7 | if total_seconds < 60 8 | "#{seconds.to_i}s" 9 | else 10 | "#{minutes.to_i}m #{seconds.to_i}s" 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/kubes/version.rb: -------------------------------------------------------------------------------- 1 | module Kubes 2 | VERSION = "0.9.3" 3 | end 4 | -------------------------------------------------------------------------------- /lib/templates/base/.kubes/config.rb.tt: -------------------------------------------------------------------------------- 1 | Kubes.configure do |config| 2 | config.repo = "<%= @options[:repo] %>" 3 | # config.logger.level = "debug" 4 | # config.layering.show = true 5 | # auto-switching 6 | # config.kubectl.context = "dev-cluster" 7 | # config.kubectl.context_keep = true # keep context after switching 8 | # config.kubectl.exit_on_fail_for_apply = true # whether or not continue if the kubectl command fails 9 | # config.kubectl.exit_on_fail_for_delete = false # whether or not continue if the kubectl command fails 10 | end 11 | -------------------------------------------------------------------------------- /lib/templates/base/.kubes/config/env/dev.rb: -------------------------------------------------------------------------------- 1 | # Here is where you override config.rb with dev settings 2 | # 3 | # Example: 4 | # Kubes.configure do |config| 5 | # config.kubectl.context = "dev-cluster" 6 | # end 7 | -------------------------------------------------------------------------------- /lib/templates/base/.kubes/config/env/prod.rb: -------------------------------------------------------------------------------- 1 | # Here is where you override config.rb with prod settings 2 | # 3 | # Example: 4 | # Kubes.configure do |config| 5 | # config.kubectl.context = "prod-cluster" 6 | # end 7 | -------------------------------------------------------------------------------- /lib/templates/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Simple example starter 2 | FROM nginx 3 | EXPOSE 80 4 | CMD ["nginx", "-g", "daemon off;"] 5 | -------------------------------------------------------------------------------- /lib/templates/dsl/.kubes/resources/base/all.rb.tt: -------------------------------------------------------------------------------- 1 | <% 2 | unless namespace == "default" 3 | namespace_line = %Q|namespace "#{namespace}"\n| 4 | end 5 | -%> 6 | <%= namespace_line if namespace_line -%> 7 | labels(app: "<%= app %>") 8 | -------------------------------------------------------------------------------- /lib/templates/dsl/.kubes/resources/shared/namespace.rb.tt: -------------------------------------------------------------------------------- 1 | name "<%= namespace %>" 2 | labels(app: "<%= app %>") 3 | -------------------------------------------------------------------------------- /lib/templates/dsl/.kubes/resources/web/deployment.rb: -------------------------------------------------------------------------------- 1 | name "web" 2 | labels(role: "web") 3 | 4 | replicas 1 # overridden on a env basis 5 | image docker_image # IE: user/<%= app %>:kubes-2020-06-13T19-55-16-43afc6e 6 | 7 | # revisionHistoryLimit 1 # uncomment to reduce old ReplicaSets, default is 10 https://bit.ly/3hqrzyP 8 | # maxUnavailable 25 9 | 10 | # More docs: kubes.guru/docs/dsl/resources/deployment/ 11 | 12 | -------------------------------------------------------------------------------- /lib/templates/dsl/.kubes/resources/web/deployment/dev.rb: -------------------------------------------------------------------------------- 1 | replicas 1 2 | -------------------------------------------------------------------------------- /lib/templates/dsl/.kubes/resources/web/deployment/prod.rb: -------------------------------------------------------------------------------- 1 | replicas 2 2 | -------------------------------------------------------------------------------- /lib/templates/dsl/.kubes/resources/web/service.rb: -------------------------------------------------------------------------------- 1 | name "web" 2 | labels(role: "web") 3 | 4 | # Optional since default port is 80 5 | # port 80 6 | targetPort dockerfile_port # expose port in Dockerfile 7 | 8 | # More docs: kubes.guru/docs/dsl/resources/service/ 9 | -------------------------------------------------------------------------------- /lib/templates/new/helper/file.rb: -------------------------------------------------------------------------------- 1 | module <%= underscored_name.camelize %> 2 | end 3 | -------------------------------------------------------------------------------- /lib/templates/new/hooks/docker.rb: -------------------------------------------------------------------------------- 1 | # Docs: https://kubes.guru/docs/config/hooks/docker/ 2 | 3 | before("build", 4 | execute: "echo 'docker build before hook'", 5 | ) 6 | 7 | after("build", 8 | execute: "echo 'docker build after hook'", 9 | ) 10 | -------------------------------------------------------------------------------- /lib/templates/new/hooks/kubectl.rb: -------------------------------------------------------------------------------- 1 | # Docs: https://kubes.guru/docs/config/hooks/kubectl/ 2 | 3 | before("apply", 4 | on: "web/deployment", 5 | execute: "echo 'before apply hook test'", 6 | ) 7 | 8 | after("delete", 9 | on: "web/deployment", 10 | execute: "echo 'after delete hook test'", 11 | ) 12 | -------------------------------------------------------------------------------- /lib/templates/new/hooks/kubes.rb: -------------------------------------------------------------------------------- 1 | # Docs: https://kubes.guru/docs/config/hooks/kubes/ 2 | 3 | before("apply", 4 | execute: "echo 'kubes before apply hook'", 5 | ) 6 | 7 | after("apply", 8 | execute: "echo 'kubes after apply hook'", 9 | ) 10 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/backend_config.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | spec( 3 | timeoutSec: 40, 4 | connectionDraining: { 5 | drainingTimeoutSec: 60, 6 | }, 7 | sessionAffinity: { 8 | affinityType: "CLIENT_IP", 9 | } 10 | ) 11 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/config_map.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | data( 3 | KEY1: "value1", 4 | KEY2: "value2", 5 | ) 6 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/daemon_set.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | labels("app": "<%= app %>") 3 | updateStrategy( 4 | type: "RollingUpdate", 5 | rollingUpdate: { 6 | maxUnavailable: 1 7 | } 8 | ) 9 | # annotations( 10 | # "*scheduler**.alpha.kubernetes.io/critical-pod": '*' 11 | # ) 12 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/deployment.rb: -------------------------------------------------------------------------------- 1 | name "<%= role %>" 2 | labels(role: "<%= role %>") 3 | replicas 2 4 | image "<%%= docker_image %>" 5 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/endpoint.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | addresses(["1.1.1.1"]) 3 | ports(["80"]) 4 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/ingress.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | serviceName "<%= app %>" 3 | servicePort 80 4 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/job.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | image(docker_image) 3 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/managed_certificate.rb: -------------------------------------------------------------------------------- 1 | name "cert1" 2 | domains(["cert1.example.com"]) 3 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/namespace.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | labels(app: "<%= app %>") # useful with NetworkPolicy 3 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/network_policy.rb: -------------------------------------------------------------------------------- 1 | name "web" 2 | labels(app: "<%= app %>") # IE: backend 3 | namespace "<%= app %>" # IE: backend 4 | 5 | matchLabels(app: "<%= app %>", role: "<%= role %>") # IE: app: backend 6 | fromNamespace(app: "<%= app %>") # IE: app: frontend 7 | fromPod(app: "<%= app %>") # IE: backend 8 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/pod.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | containers([ 3 | image: docker_image, 4 | command: ["sleep", "3600"], 5 | name: "<%= app %>", 6 | ]) 7 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/role.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | apiGroups([""]) 3 | resources(["pods"]) 4 | verbs(["get", "watch", "list"]) 5 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/role_binding.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | 3 | subjects([ 4 | {kind: "User", name: "me@email.com"}, 5 | ]) 6 | 7 | roleName "<%= app %>" 8 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/secret.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | data( 3 | username: base64("user"), 4 | password: base64("pass"), 5 | ) 6 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/service.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | labels(role: "<%= role %>") 3 | -------------------------------------------------------------------------------- /lib/templates/new/resource/dsl/service_account.rb: -------------------------------------------------------------------------------- 1 | name "<%= app %>" 2 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/backend_config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cloud.google.com/v1 2 | kind: BackendConfig 3 | metadata: 4 | name: <%= app %> 5 | spec: 6 | timeoutSec: 40 7 | connectionDraining: 8 | drainingTimeoutSec: 60 9 | sessionAffinity: 10 | affinityType: CLIENT_IP 11 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/config_map.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: <%= app %> 5 | labels: 6 | app: <%= app %> 7 | data: 8 | KEY1: value1 9 | KEY2: value2 10 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/daemon_set.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: DaemonSet 3 | metadata: 4 | name: <%= app %> 5 | labels: 6 | app: <%= app %> 7 | spec: 8 | updateStrategy: 9 | type: RollingUpdate 10 | rollingUpdate: 11 | maxUnavailable: 1 12 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: <%= role %> 5 | labels: 6 | role: <%= role %> 7 | spec: 8 | replicas: 1 # overridden on a env basis 9 | selector: 10 | matchLabels: 11 | role: <%= role %> 12 | template: 13 | metadata: 14 | labels: 15 | role: <%= role %> 16 | spec: 17 | containers: 18 | - name: <%= role %> 19 | image: <%%= docker_image %> 20 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/endpoint.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Endpoints 3 | metadata: 4 | name: <%= app %> 5 | subsets: 6 | - addresses: 7 | - ip: 192.0.2.42 8 | ports: 9 | - port: 9376 10 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: <%= role %> 5 | spec: 6 | defaultBackend: 7 | service: 8 | name: web 9 | port: 10 | number: 80 11 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/job.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: <%= app %> 5 | spec: 6 | template: 7 | spec: 8 | restartPolicy: Never 9 | serviceAccountName: <%= app %> 10 | containers: 11 | - name: <%= app %> 12 | image: <%%= docker_image %> 13 | command: ["uptime"] # IE: ["bin/job/migrate.sh"] 14 | # envFrom: 15 | # - secretRef: 16 | # name: <%= app %> 17 | # - configMapRef: 18 | # name: <%= app %> 19 | backoffLimit: 1 20 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/managed_certificate.yaml: -------------------------------------------------------------------------------- 1 | # Docs: https://cloud.google.com/kubernetes-engine/docs/how-to/managed-certs#setting_up_a_google-managed_certificate 2 | # https://kubes.guru/docs/dsl/resources/managed_certificate/ 3 | apiVersion: networking.gke.io/v1 4 | kind: ManagedCertificate 5 | metadata: 6 | name: managed-cert 7 | spec: 8 | domains: 9 | - subdomain1.example.com 10 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: <%= app %>-<%%= Kubes.env %> 5 | labels: 6 | app: <%= app %> 7 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/network_policy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: NetworkPolicy 3 | metadata: 4 | name: <%= role %> 5 | labels: 6 | app: <%= app %> # IE: backend 7 | namespace: <%= app %> # IE: backend 8 | spec: 9 | podSelector: 10 | matchLabels: 11 | app: <%= app %> # IE: backend 12 | role: <%= role %> 13 | ingress: 14 | - from: 15 | - namespaceSelector: 16 | matchLabels: 17 | app: <%= app %> # IE: frontend 18 | - podSelector: 19 | matchLabels: 20 | app: <%= app %> # IE: backend 21 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: <%= app %> 5 | spec: 6 | containers: 7 | - image: <%%= docker_image %> 8 | command: 9 | - sleep 10 | - '3600' 11 | name: <%= app %> 12 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: Role 3 | metadata: 4 | name: <%= app %> 5 | rules: 6 | - apiGroups: 7 | - '' 8 | resources: 9 | - pods 10 | verbs: 11 | - get 12 | - watch 13 | - list 14 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/role_binding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: RoleBinding 3 | metadata: 4 | name: <%= app %> 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: Role 8 | name: <%= app %> 9 | subjects: 10 | - kind: User 11 | name: me@email.com 12 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: <%= app %> 5 | labels: 6 | app: <%= app %> 7 | data: 8 | username: <%%= base64("user") %> 9 | password: <%%= base64("pass") %> 10 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: <%= role %> 5 | labels: 6 | role: <%= role %> 7 | spec: 8 | ports: 9 | - port: 80 10 | protocol: TCP 11 | targetPort: <%%= dockerfile_port %> 12 | selector: 13 | role: <%= role %> 14 | type: ClusterIP 15 | -------------------------------------------------------------------------------- /lib/templates/new/resource/yaml/service_account.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: <%= app %> 5 | -------------------------------------------------------------------------------- /lib/templates/new/variable/file.rb: -------------------------------------------------------------------------------- 1 | @example = "<%= Kubes.env %>-value" 2 | -------------------------------------------------------------------------------- /lib/templates/yaml/.kubes/resources/base/all.yaml.tt: -------------------------------------------------------------------------------- 1 | metadata: 2 | namespace: <%= namespace %> 3 | labels: 4 | app: <%= app %> 5 | -------------------------------------------------------------------------------- /lib/templates/yaml/.kubes/resources/base/deployment.yaml.tt: -------------------------------------------------------------------------------- 1 | spec: 2 | selector: 3 | matchLabels: 4 | app: <%= app %> 5 | env: <%= Kubes.env %> 6 | template: 7 | metadata: 8 | labels: 9 | app: <%= app %> 10 | env: <%= Kubes.env %> 11 | -------------------------------------------------------------------------------- /lib/templates/yaml/.kubes/resources/shared/namespace.yaml.tt: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: <%= namespace %> 5 | -------------------------------------------------------------------------------- /lib/templates/yaml/.kubes/resources/web/deployment.yaml.tt: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: web 5 | labels: 6 | role: web 7 | spec: 8 | replicas: 1 # overridden on a env basis 9 | selector: 10 | matchLabels: 11 | role: web 12 | template: 13 | metadata: 14 | labels: 15 | role: web 16 | spec: 17 | containers: 18 | - name: web 19 | image: <%%= docker_image %> 20 | -------------------------------------------------------------------------------- /lib/templates/yaml/.kubes/resources/web/deployment/dev.yaml: -------------------------------------------------------------------------------- 1 | spec: 2 | replicas: 1 3 | -------------------------------------------------------------------------------- /lib/templates/yaml/.kubes/resources/web/deployment/prod.yaml: -------------------------------------------------------------------------------- 1 | spec: 2 | replicas: 2 3 | -------------------------------------------------------------------------------- /lib/templates/yaml/.kubes/resources/web/service.yaml.tt: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: web 5 | labels: 6 | role: web 7 | spec: 8 | ports: 9 | - port: 80 10 | protocol: TCP 11 | targetPort: <%%= dockerfile_port %> 12 | selector: 13 | role: web 14 | type: ClusterIP 15 | -------------------------------------------------------------------------------- /spec/cli_spec.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::CLI do 2 | describe "kubes" do 3 | it "generate" do 4 | out = execute("exe/kubes compile #{@args}") 5 | # expect(out).to include("from: Tung\nHello world") 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/fixtures/artifacts/demo-web/deployment.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: demo-web 6 | labels: 7 | app: demo-web 8 | namespace: default 9 | spec: 10 | replicas: 1 11 | selector: 12 | matchLabels: 13 | app: demo-web 14 | strategy: 15 | rollingUpdate: 16 | maxSurge: 25 17 | maxUnavailable: 25 18 | type: RollingUpdate 19 | template: 20 | metadata: 21 | labels: 22 | app: demo-web 23 | spec: 24 | containers: 25 | - image: 111111111111.dkr.ecr.us-west-2.amazonaws.com/demo:kubes-2020-06-20T03-55-34 26 | name: demo-web 27 | -------------------------------------------------------------------------------- /spec/fixtures/artifacts/demo-web/service.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: demo-web 6 | labels: 7 | app: demo-web 8 | namespace: default 9 | spec: 10 | ports: 11 | - port: 80 12 | protocol: TCP 13 | targetPort: 80 14 | selector: 15 | app: demo-web 16 | type: ClusterIP 17 | -------------------------------------------------------------------------------- /spec/fixtures/blocks/deployments.rb: -------------------------------------------------------------------------------- 1 | deployment "demo-web" do 2 | labels(app: name) 3 | image "nginx" 4 | end 5 | 6 | deployment "demo-web-2" do 7 | labels(app: name) 8 | image "nginx" 9 | end 10 | -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/both/envFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | envFrom: 23 | - secretRef: 24 | name: demo-secret 25 | - configMapRef: 26 | name: demo-config-map 27 | - configMapRef: 28 | name: demo-config-map-2 29 | replicas: 1 30 | apiVersion: apps/v1 31 | kind: Deployment 32 | -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/both/valueFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | env: 23 | - name: MYSQL_ROOT_PASSWORD 24 | valueFrom: 25 | configMapKeyRef: 26 | name: demo-config-map 27 | key: password 28 | secretKeyRef: 29 | name: demo-secret 30 | key: password 31 | replicas: 1 32 | apiVersion: apps/v1 33 | kind: Deployment -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/both/volumes.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | volumeMounts: 23 | - mountPath: /config-map 24 | name: config-map-volume 25 | volumes: 26 | - configMap: 27 | name: demo-config-map 28 | items: 29 | - key: k1 30 | path: config-map.conf 31 | name: config-map-volume 32 | - secret: 33 | secretName: demo-secret 34 | items: 35 | - key: k1 36 | path: secrets.conf 37 | name: secrets-volume 38 | replicas: 1 39 | apiVersion: apps/v1 40 | kind: Pod -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/configMap/envFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | envFrom: 23 | - configMapRef: 24 | name: demo-config-map 25 | replicas: 1 26 | apiVersion: apps/v1 27 | kind: Deployment -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/configMap/valueFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | env: 23 | - name: MYSQL_ROOT_PASSWORD 24 | valueFrom: 25 | configMapKeyRef: 26 | name: demo-config-map 27 | key: password 28 | replicas: 1 29 | apiVersion: apps/v1 30 | kind: Deployment -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/configMap/volumes-name-first.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # apiVersion: apps/v1 3 | # kind: Deployment 4 | # spec: 5 | # template: 6 | # spec: 7 | # only including structure needed for spec 8 | volumes: 9 | - name: config-map-volume 10 | configMap: 11 | name: demo-config-map 12 | items: 13 | - key: k1 14 | path: config-map.conf 15 | -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/configMap/volumes-name-second.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # apiVersion: apps/v1 3 | # kind: Deployment 4 | # spec: 5 | # template: 6 | # spec: 7 | # only including structure needed for spec 8 | volumes: 9 | - configMap: 10 | name: demo-config-map 11 | items: 12 | - key: k1 13 | path: config-map.conf 14 | name: config-map-volume 15 | -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/configMap/volumes.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | volumeMounts: 23 | - mountPath: /config-map 24 | name: config-map-volume 25 | volumes: 26 | - configMap: 27 | name: demo-config-map 28 | items: 29 | - key: k1 30 | path: config-map.conf 31 | name: config-map-volume 32 | replicas: 1 33 | apiVersion: apps/v1 34 | kind: Pod -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/secret/envFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | envFrom: 23 | - secretRef: 24 | name: demo-secret 25 | replicas: 1 26 | apiVersion: apps/v1 27 | kind: Deployment -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/secret/valueFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | env: 23 | - name: MYSQL_ROOT_PASSWORD 24 | valueFrom: 25 | secretKeyRef: 26 | name: demo-secret 27 | key: password 28 | replicas: 1 29 | apiVersion: apps/v1 30 | kind: Deployment -------------------------------------------------------------------------------- /spec/fixtures/decorators/deployment/secret/volumes.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | labels: 5 | app: demo 6 | role: web 7 | name: demo-web 8 | spec: 9 | selector: 10 | matchLabels: 11 | app: demo 12 | role: web 13 | template: 14 | metadata: 15 | labels: 16 | app: demo 17 | role: web 18 | spec: 19 | containers: 20 | - name: demo-web 21 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 22 | volumeMounts: 23 | - mountPath: /secrets 24 | name: secrets-volume 25 | volumes: 26 | - secret: 27 | secretName: demo-secret 28 | items: 29 | - key: k1 30 | path: secrets.conf 31 | name: secrets-volume 32 | replicas: 1 33 | apiVersion: apps/v1 34 | kind: Pod -------------------------------------------------------------------------------- /spec/fixtures/decorators/ingress/tls.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: web 5 | spec: 6 | tls: 7 | - secretName: tls-secret 8 | defaultBackend: 9 | service: 10 | name: web 11 | port: 12 | number: 80 13 | -------------------------------------------------------------------------------- /spec/fixtures/decorators/pod/configMap/envFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | name: demo-web 4 | spec: 5 | containers: 6 | - name: demo-web 7 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 8 | envFrom: 9 | - configMapRef: 10 | name: demo-config-map 11 | apiVersion: apps/v1 12 | kind: Pod -------------------------------------------------------------------------------- /spec/fixtures/decorators/pod/configMap/valueFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | name: demo-web 5 | spec: 6 | containers: 7 | - name: demo-web 8 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 9 | env: 10 | - name: MYSQL_ROOT_PASSWORD 11 | valueFrom: 12 | configMapKeyRef: 13 | name: demo-config-map 14 | key: password 15 | apiVersion: apps/v1 16 | kind: Pod -------------------------------------------------------------------------------- /spec/fixtures/decorators/pod/configMap/volumes.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | name: demo-pod 4 | spec: 5 | containers: 6 | - name: demo-pod 7 | image: gcr.io/project/demo-pod:kubes-2020-06-23T00-07-54 8 | volumeMounts: 9 | - mountPath: /config-map 10 | name: config-map-volume 11 | volumes: 12 | - configMap: 13 | name: demo-config-map 14 | items: 15 | - key: k1 16 | path: config-map.conf 17 | name: config-map-volume 18 | apiVersion: apps/v1 19 | kind: Deployment -------------------------------------------------------------------------------- /spec/fixtures/decorators/pod/secret/envFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | name: demo-web 4 | spec: 5 | containers: 6 | - name: demo-web 7 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 8 | envFrom: 9 | - secretRef: 10 | name: demo-secret 11 | apiVersion: apps/v1 12 | kind: Pod -------------------------------------------------------------------------------- /spec/fixtures/decorators/pod/secret/valueFrom.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | namespace: default 4 | name: demo-web 5 | spec: 6 | containers: 7 | - name: demo-web 8 | image: gcr.io/project/demo-web:kubes-2020-06-23T00-07-54 9 | env: 10 | - name: MYSQL_ROOT_PASSWORD 11 | valueFrom: 12 | secretKeyRef: 13 | name: demo-secret 14 | key: password 15 | apiVersion: apps/v1 16 | kind: Pod -------------------------------------------------------------------------------- /spec/fixtures/decorators/pod/secret/volumes.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metadata: 3 | name: demo-pod 4 | spec: 5 | containers: 6 | - name: demo-pod 7 | image: gcr.io/project/demo-pod:kubes-2020-06-23T00-07-54 8 | volumeMounts: 9 | - mountPath: /secrets 10 | name: secrets-volume 11 | volumes: 12 | - secret: 13 | secretName: demo-secret 14 | items: 15 | - key: k1 16 | path: secrets.conf 17 | name: secrets-volume 18 | apiVersion: apps/v1 19 | kind: Deployment -------------------------------------------------------------------------------- /spec/fixtures/deployments/minimum.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | image "nginx" 3 | 4 | # labels(app: name) 5 | # namespace "default" 6 | -------------------------------------------------------------------------------- /spec/fixtures/deployments/props.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | namespace "default" 4 | 5 | replicas 2 6 | image "nginx" 7 | containerPort 81 8 | -------------------------------------------------------------------------------- /spec/fixtures/deployments/setter/container.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | namespace "default" 4 | 5 | container( 6 | name: name, 7 | image: "nginx", 8 | ports: [ 9 | containerPort: 88 10 | ] 11 | ) 12 | -------------------------------------------------------------------------------- /spec/fixtures/deployments/setter/containers.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | namespace "default" 4 | 5 | containers([{ 6 | name: name, 7 | image: "nginx", 8 | ports: [ 9 | containerPort: 88 10 | ] 11 | },{ 12 | name: "sidecar", 13 | image: "tongueroo/sinatra", 14 | }]) 15 | -------------------------------------------------------------------------------- /spec/fixtures/deployments/setter/metadata.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | namespace "default" 3 | labels(app: name) 4 | 5 | metadata( 6 | name: name, 7 | labels: labels.merge(label2: "value2"), 8 | namespace: namespace, 9 | ) 10 | spec( 11 | replicas: 3, 12 | selector: {matchLabels: labels}, 13 | strategy: strategy, 14 | template: template, 15 | ) 16 | -------------------------------------------------------------------------------- /spec/fixtures/deployments/setter/sidecar.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | 4 | image "nginx" 5 | 6 | sidecar( 7 | name: "sidecar", 8 | image: "tongueroo/sinatra", 9 | ports: [ 10 | containerPort: 88 11 | ] 12 | ) 13 | -------------------------------------------------------------------------------- /spec/fixtures/deployments/setter/spec.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | namespace "default" 4 | 5 | spec( 6 | replicas: 3, 7 | selector: {matchLabels: labels}, 8 | strategy: strategy, 9 | template: template, 10 | ) 11 | -------------------------------------------------------------------------------- /spec/fixtures/multiple-files/.kubes/resources/web/deployment-1.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | replicas 2 4 | image "nginx" 5 | -------------------------------------------------------------------------------- /spec/fixtures/multiple-files/.kubes/resources/web/deployment-2.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | replicas 2 4 | image "nginx" 5 | -------------------------------------------------------------------------------- /spec/fixtures/project/.gitignore: -------------------------------------------------------------------------------- 1 | .kubes/output 2 | -------------------------------------------------------------------------------- /spec/fixtures/project/.kubes/resources/web/deployment.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | labels(app: name) 3 | namespace "default" 4 | 5 | replicas 2 6 | image "nginx" 7 | containerPort 80 8 | 9 | # More examples: 10 | # container([ 11 | # name: name, 12 | # image: "nginx", 13 | # ports: [ 14 | # containerPort: 80 15 | # ] 16 | # ]) 17 | 18 | # spec( 19 | # replicas: replicas || 1, 20 | # selector: {matchLabels: labels}, 21 | # strategy: strategy, 22 | # test: "me", 23 | # template: template, 24 | # ) 25 | 26 | # containers([ 27 | # name: name, 28 | # image: "nginx", 29 | # ports: [ 30 | # containerPort: 80 31 | # ] 32 | # ]) 33 | -------------------------------------------------------------------------------- /spec/fixtures/project/.kubes/resources/web/empty.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boltops-tools/kubes/94b80f0cbf8bb0ead1bb3b8b1946ee14a74579ca/spec/fixtures/project/.kubes/resources/web/empty.rb -------------------------------------------------------------------------------- /spec/fixtures/project/.kubes/resources/web/service.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | port 80 3 | targetPort 3000 4 | -------------------------------------------------------------------------------- /spec/fixtures/services/minimum.rb: -------------------------------------------------------------------------------- 1 | name "demo-web" 2 | port 81 3 | targetPort 3001 -------------------------------------------------------------------------------- /spec/fixtures/syntax/.kubes/resources/web/network_policy.rb: -------------------------------------------------------------------------------- 1 | name "demo-web-allow-tester" 2 | matchLabels(role: "web") 3 | fromPod(run: "tester") 4 | -------------------------------------------------------------------------------- /spec/fixtures/syntax/.kubes/resources/web/pod.rb: -------------------------------------------------------------------------------- 1 | name "demo-pod" 2 | -------------------------------------------------------------------------------- /spec/kubes/compiler/decorator/post/ingress_spec.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::Compiler::Decorator::Post do 2 | let(:decorator) { described_class.new(data) } 3 | 4 | def fixture(name) 5 | YAML.load_file("spec/fixtures/decorators/ingress/#{name}.yaml") 6 | end 7 | before(:each) do 8 | allow(Kubes::Compiler::Decorator::Hashable::Storage).to receive(:fetch).and_return("fakehash") 9 | end 10 | 11 | context "ingress" do 12 | describe "tls" do 13 | let(:data) { fixture("tls") } 14 | it "run" do 15 | decorator.run 16 | data = decorator.data 17 | name = data['spec']['tls'][0]['secretName'] 18 | expect(name).to eq("tls-secret-fakehash") 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/kubes/compiler_spec.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::Compiler do 2 | let(:compiler) do 3 | compiler = described_class.new(options) 4 | allow(compiler).to receive(:write_full) 5 | compiler 6 | end 7 | let(:options) { {path: "spec/fixtures/project/.kubes/resources/web/deployment.rb" } } 8 | 9 | describe "compiler" do 10 | it "run" do 11 | compiler.run 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/kubes/dsl/daemon_set.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::Compiler::Dsl::Syntax::DaemonSet do 2 | let(:evaluator) { described_class.new(options) } 3 | let(:options) { {path: fixture("syntax/daemon_set") } } 4 | 5 | context "DaemonSet" do 6 | it "run" do 7 | data = evaluator.run 8 | expect(data['kind']).to eq "DaemonSet" 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/kubes/dsl/network_policy_spec.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::Compiler::Dsl::Syntax::NetworkPolicy do 2 | let(:evaluator) { described_class.new(options) } 3 | let(:options) { {path: fixture("syntax/.kubes/resources/web/network_policy") } } 4 | 5 | context "network_policy" do 6 | it "run" do 7 | data = evaluator.run 8 | expect(data['kind']).to eq "NetworkPolicy" 9 | # fromMatchLabels 10 | from = data['spec']['ingress'].first['from'].first 11 | expect(from['podSelector']['matchLabels']['run']).to eq "tester" 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/kubes/dsl/pod_spec.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::Compiler::Dsl::Syntax::Pod do 2 | let(:evaluator) { described_class.new(options) } 3 | let(:options) { {path: fixture("syntax/.kubes/resources/web/pod") } } 4 | 5 | context "pod" do 6 | it "run" do 7 | data = evaluator.run 8 | expect(data['kind']).to eq "Pod" 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/kubes/dsl/service_spec.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::Compiler::Dsl::Syntax::Service do 2 | let(:evaluator) { described_class.new(options) } 3 | let(:options) { {path: fixture("services/#{deployment_name}") } } 4 | 5 | context "minimum" do 6 | let(:deployment_name) { "minimum" } 7 | it "run" do 8 | data = evaluator.run 9 | expect(data['spec']['type']).to eq "ClusterIP" 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /spec/kubes/kubectl/batch_spec.rb: -------------------------------------------------------------------------------- 1 | describe Kubes::Kubectl::Batch do 2 | let(:batch) { described_class.new(options) } 3 | let(:options) { {} } 4 | 5 | describe "batch" do 6 | let(:files) do 7 | %w[ 8 | .kubes/output/clock/deployment.yaml 9 | .kubes/output/web/deployment.yaml 10 | .kubes/output/web/ingress.yaml 11 | .kubes/output/web/service.yaml 12 | ] 13 | end 14 | 15 | it "sorted_files" do 16 | allow(batch).to receive(:files).and_return(files) 17 | expect(batch.sorted_files).to eq( 18 | [".kubes/output/clock/deployment.yaml", 19 | ".kubes/output/web/service.yaml", 20 | ".kubes/output/web/deployment.yaml", 21 | ".kubes/output/web/ingress.yaml"]) # ingress should be at the end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["KUBES_TEST"] = "1" 2 | ENV['KUBES_ROOT'] = "spec/fixtures/project" 3 | 4 | # CodeClimate test coverage: https://docs.codeclimate.com/docs/configuring-test-coverage 5 | # require 'simplecov' 6 | # SimpleCov.start 7 | 8 | require "pp" 9 | require "byebug" 10 | root = File.expand_path("../", File.dirname(__FILE__)) 11 | require "#{root}/lib/kubes" 12 | 13 | module Helper 14 | def execute(cmd) 15 | puts "Running: #{cmd}" if show_command? 16 | out = `#{cmd}` 17 | puts out if show_command? 18 | out 19 | end 20 | 21 | # Added SHOW_COMMAND because DEBUG is also used by other libraries like 22 | # bundler and it shows its internal debugging logging also. 23 | def show_command? 24 | ENV['DEBUG'] || ENV['SHOW_COMMAND'] 25 | end 26 | 27 | def fixture(name) 28 | "spec/fixtures/#{name}.rb" 29 | end 30 | end 31 | 32 | RSpec.configure do |c| 33 | c.include Helper 34 | end 35 | --------------------------------------------------------------------------------