{"id":38094460,"url":"https://github.com/fkorotkov/k8s-kotlin-dsl","last_synced_at":"2026-01-18T12:31:05.891Z","repository":{"id":39618375,"uuid":"84911320","full_name":"fkorotkov/k8s-kotlin-dsl","owner":"fkorotkov","description":"Kotlin DSL for Kubernetes configs","archived":false,"fork":false,"pushed_at":"2025-01-24T17:56:46.000Z","size":1577,"stargazers_count":354,"open_issues_count":5,"forks_count":21,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-10-29T15:49:51.546Z","etag":null,"topics":["dsl","generator","kotlin","kotlin-dsl","kubernetes","kubernetes-deployment","kubernetes-setup"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fkorotkov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-14T06:01:29.000Z","updated_at":"2025-10-24T16:35:42.000Z","dependencies_parsed_at":"2022-07-13T05:10:26.031Z","dependency_job_id":null,"html_url":"https://github.com/fkorotkov/k8s-kotlin-dsl","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/fkorotkov/k8s-kotlin-dsl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkorotkov%2Fk8s-kotlin-dsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkorotkov%2Fk8s-kotlin-dsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkorotkov%2Fk8s-kotlin-dsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkorotkov%2Fk8s-kotlin-dsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fkorotkov","download_url":"https://codeload.github.com/fkorotkov/k8s-kotlin-dsl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkorotkov%2Fk8s-kotlin-dsl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28536002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsl","generator","kotlin","kotlin-dsl","kubernetes","kubernetes-deployment","kubernetes-setup"],"created_at":"2026-01-16T21:00:23.269Z","updated_at":"2026-01-18T12:31:05.867Z","avatar_url":"https://github.com/fkorotkov.png","language":"Kotlin","funding_links":[],"categories":["Configuration Management"],"sub_categories":[],"readme":"[![Build Status](https://api.cirrus-ci.com/github/fkorotkov/k8s-kotlin-dsl.svg)](https://cirrus-ci.com/github/fkorotkov/k8s-kotlin-dsl)\n[![](https://jitpack.io/v/fkorotkov/k8s-kotlin-dsl.svg)](https://jitpack.io/#fkorotkov/k8s-kotlin-dsl)\n\n[Kotlin](https://kotlinlang.org) DSL for [Kubernetes](https://kubernetes.io/) and [Openshift Container Platform](https://www.openshift.com/container-platform/) on top of [fabric8 client](https://github.com/fabric8io/kubernetes-client).\n\n![screencast](demo.gif)\n\n## Usage\n\n`k8s-kotlin-dsl` package can be found on [jitpack](https://jitpack.io/#fkorotkov/k8s-kotlin-dsl). Simply add following lines to your `build.gradle`:\n \n ```groovy\nallprojects {\n\t\trepositories {\n\t\t\t maven { url 'https://jitpack.io' }\n\t\t}\n}\n\ndependencies {\n    implementation(\"com.github.fkorotkov:k8s-kotlin-dsl:${kubernetes_dsl_version}\")\n}\n```\n\n### Using with `kubernetes-client`\n\nLet's check out how to create an Ingress via [fabric8 client](https://github.com/fabric8io/kubernetes-client). Don't forget to add a dependency on `io.fabric8:kubernetes-client:${kubernetes_client_version}`.\n\n```kotlin\nimport com.fkorotkov.kubernetes.extensions.*\nimport io.fabric8.kubernetes.api.model.IntOrString\nimport io.fabric8.kubernetes.client.DefaultKubernetesClient\n\n\nfun main() {\n  val client = DefaultKubernetesClient().inNamespace(\"default\")\n  client.extensions().ingresses().createOrReplace(\n    newIngress {\n      metadata {\n        name = \"example-ingress\"\n      }\n      spec {\n        backend {\n          serviceName = \"example-service\"\n          servicePort = IntOrString(8080)\n        }\n      }\n    }\n  )\n}\n```\n\n### Apply modifications\n\nBy leveraging awesomeness of Kotlin it becomes super easy to have a base service template that every microservice is created from:\n \n```kotlin\nval baseService = defaultServiceTemplate()\nbaseService.apply {\n  metadata {\n    name = \"foo\"\n  }\n}\n```\n\n### Complete Deployment example\n\nHere is an example of `BaseDeployment` that defines a deployment with one replica and mounts a secret that can be used by the service.\n\n```kotlin\nimport com.fkorotkov.kubernetes.*\nimport com.fkorotkov.kubernetes.apps.*\nimport io.fabric8.kubernetes.api.model.IntOrString\nimport io.fabric8.kubernetes.api.model.apps.Deployment\n\nclass BaseDeployment : Deployment {\n  constructor(serviceName: String) {\n    metadata {\n      name = \"$serviceName-service-deployment\"\n      labels = mapOf(\n        \"app\" to serviceName,\n        \"tier\" to \"backend\"\n      )\n    }\n    spec {\n      replicas = 1\n      template {\n        metadata {\n          labels = mapOf(\n            \"app\" to serviceName,\n            \"tier\" to \"backend\"\n          )\n        }\n        spec {\n          containers = listOf(\n            newContainer {\n              name = \"$serviceName-service\"\n              image = \"gcr.io/fkorotkov/$serviceName-service:latest\"\n              volumeMounts = listOf(\n                newVolumeMount {\n                  name = \"gcp-credentials\"\n                  mountPath = \"/etc/credentials\"\n                  readOnly = true\n                }\n              )\n              env = listOf(\n                newEnvVar {\n                  name = \"GOOGLE_APPLICATION_CREDENTIALS\"\n                  value = \"/etc/credentials/service-account-credentials.json\"\n                }\n              )\n              ports = listOf(\n                newContainerPort {\n                  containerPort = 8080\n                }\n              )\n              livenessProbe {\n                httpGet {\n                  path = \"/healthz\"\n                  port = IntOrString(8080)\n                }\n                periodSeconds = 60\n              }\n              readinessProbe {\n                httpGet {\n                  path = \"/healthz\"\n                  port = IntOrString(8080)\n                }\n                initialDelaySeconds = 10\n                periodSeconds = 60\n              }\n            }\n          )\n          volumes = listOf(\n            newVolume {\n              name = \"gcp-credentials\"\n              secret {\n                secretName = \"gcp-credentials\"\n              }\n            }\n          )\n        }\n      }\n    }\n  }\n}\n```\n\n## Contribution\n\nCheck `CONTRIBUTING.md`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkorotkov%2Fk8s-kotlin-dsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffkorotkov%2Fk8s-kotlin-dsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkorotkov%2Fk8s-kotlin-dsl/lists"}