All Projects → fkorotkov → K8s Kotlin Dsl

fkorotkov / K8s Kotlin Dsl

Licence: mit
Kotlin DSL for Kubernetes configs

Programming Languages

kotlin
9241 projects
dsl
153 projects

Projects that are alternatives of or similar to K8s Kotlin Dsl

Kubernaut
Instant ephemeral Kubernetes clusters for development and testing
Stars: ✭ 115 (-55.6%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
Kubernix
Single dependency Kubernetes clusters for local testing, experimenting and development
Stars: ✭ 545 (+110.42%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
Eksctl
The official CLI for Amazon EKS
Stars: ✭ 3,550 (+1270.66%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
django-on-k8s
An end to end tutorial to run a Django Web Application having a PostgreSQL database in Kubernetes
Stars: ✭ 37 (-85.71%)
Mutual labels:  kubernetes-setup, kubernetes-deployment
Blackbelt Aks Hackfest
Microsoft Intelligent Cloud Blackbelt Team :: Hackfest Repo
Stars: ✭ 209 (-19.31%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
Terraform Aws Eks
Terraform module to create an Elastic Kubernetes (EKS) cluster and associated worker instances on AWS
Stars: ✭ 2,464 (+851.35%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
Kubekit
A Kubernetes deployment toolkit for offline environment.
Stars: ✭ 328 (+26.64%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
Sonobuoy
Sonobuoy is a diagnostic tool that makes it easier to understand the state of a Kubernetes cluster by running a set of Kubernetes conformance tests and other plugins in an accessible and non-destructive manner.
Stars: ✭ 2,442 (+842.86%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
Metalk8s
An opinionated Kubernetes distribution with a focus on long-term on-prem deployments
Stars: ✭ 217 (-16.22%)
Mutual labels:  kubernetes-deployment, kubernetes-setup
GPU-Kubernetes-Guide
How to setup a production-grade Kubernetes GPU cluster on Paperspace in 10 minutes for $10
Stars: ✭ 34 (-86.87%)
Mutual labels:  kubernetes-setup, kubernetes-deployment
lowcode
React Lowcode - prototype, develop and maintain internal apps easier
Stars: ✭ 32 (-87.64%)
Mutual labels:  generator
built bloc
Generate the BLoC pattern boilerplate.
Stars: ✭ 51 (-80.31%)
Mutual labels:  generator
percona-qa
Percona QA is a suite of scripts and utilities that assists in building, continuous integration, automated testing & bug reporting for Percona Server, Percona XtraDB Cluster, Percona XtraBackup, Percona Server for MongoDB, as well as other flavors of MySQL (Oracle, Facebook MyQSL, WebScaleSQL, MariaDB) etc.
Stars: ✭ 55 (-78.76%)
Mutual labels:  generator
Openapi Typescript Codegen
NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification
Stars: ✭ 249 (-3.86%)
Mutual labels:  generator
docgen
The docs.json generator for discord.js and its related projects
Stars: ✭ 59 (-77.22%)
Mutual labels:  generator
color-generate
An awesome theme color generation scheme.
Stars: ✭ 165 (-36.29%)
Mutual labels:  generator
nest-js-boilerplate
Nest.js boilerplate
Stars: ✭ 79 (-69.5%)
Mutual labels:  generator
ffmpeg-commander
🛠️ FFmpeg Command Generator Web UI
Stars: ✭ 136 (-47.49%)
Mutual labels:  generator
IntuneDriveMapping
Generate PowerShell scripts to map network drives on Intune managed Windows 10 devices
Stars: ✭ 51 (-80.31%)
Mutual labels:  generator
Vue Form Generator
📋 A schema-based form generator component for Vue.js
Stars: ✭ 2,853 (+1001.54%)
Mutual labels:  generator

Build Status Download

Kotlin DSL for Kubernetes and Openshift Container Platform on top of fabric8 client.

screencast

Usage

k8s-kotlin-dsl package can be found on jcenter. Simply add following lines to your build.gradle:

repositories {
   jcenter()
} 

dependencies {
   compile("com.fkorotkov:kubernetes-dsl:${kubernetes_dsl_version}")
}

Using with kubernetes-client

Let's check out how to create an Ingress via fabric8 client. Don't forget to add a dependency on io.fabric8:kubernetes-client:${kubernetes_client_version}.

import com.fkorotkov.kubernetes.extensions.*
import io.fabric8.kubernetes.api.model.IntOrString
import io.fabric8.kubernetes.client.DefaultKubernetesClient


fun main() {
  val client = DefaultKubernetesClient().inNamespace("default")
  client.extensions().ingresses().createOrReplace(
    newIngress {
      metadata {
        name = "example-ingress"
      }
      spec {
        backend {
          serviceName = "example-service"
          servicePort = IntOrString(8080)
        }
      }
    }
  )
}

Apply modifications

By leveraging awesomeness of Kotlin it becomes super easy to have a base service template that every microservice is created from:

val baseService = defaultServiceTemplate()
baseService.apply {
  metadata {
    name = "foo"
  }
}

Complete Deployment example

Here is an example of BaseDeployment that defines a deployment with one replica and mounts a secret that can be used by the service.

import com.fkorotkov.kubernetes.*
import com.fkorotkov.kubernetes.apps.*
import io.fabric8.kubernetes.api.model.IntOrString
import io.fabric8.kubernetes.api.model.apps.Deployment

class BaseDeployment : Deployment {
  constructor(serviceName: String) {
    metadata {
      name = "$serviceName-service-deployment"
      labels = mapOf(
        "app" to serviceName,
        "tier" to "backend"
      )
    }
    spec {
      replicas = 1
      template {
        metadata {
          labels = mapOf(
            "app" to serviceName,
            "tier" to "backend"
          )
        }
        spec {
          containers = listOf(
            newContainer {
              name = "$serviceName-service"
              image = "gcr.io/fkorotkov/$serviceName-service:latest"
              volumeMounts = listOf(
                newVolumeMount {
                  name = "gcp-credentials"
                  mountPath = "/etc/credentials"
                  readOnly = true
                }
              )
              env = listOf(
                newEnvVar {
                  name = "GOOGLE_APPLICATION_CREDENTIALS"
                  value = "/etc/credentials/service-account-credentials.json"
                }
              )
              ports = listOf(
                newContainerPort {
                  containerPort = 8080
                }
              )
              livenessProbe {
                httpGet {
                  path = "/healthz"
                  port = IntOrString(8080)
                }
                periodSeconds = 60
              }
              readinessProbe {
                httpGet {
                  path = "/healthz"
                  port = IntOrString(8080)
                }
                initialDelaySeconds = 10
                periodSeconds = 60
              }
            }
          )
          volumes = listOf(
            newVolume {
              name = "gcp-credentials"
              secret {
                secretName = "gcp-credentials"
              }
            }
          )
        }
      }
    }
  }
}

Contribution

Check CONTRIBUTING.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].