{"id":20740346,"url":"https://github.com/thecoder777/k8sready-springboot","last_synced_at":"2026-04-16T15:04:25.319Z","repository":{"id":254861647,"uuid":"650136744","full_name":"TheCoder777/k8sready-springboot","owner":"TheCoder777","description":"The k8s ready springboot template is a preconfigured, scalable Springboot project with one minimal initial controller, ready to be deployed on Kubernetes. A single Gradle task outputs a finalised docker image that can be directly uploaded to an image registry of your choice.","archived":false,"fork":false,"pushed_at":"2023-06-06T12:20:50.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T01:43:58.632Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/TheCoder777.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-06T12:20:14.000Z","updated_at":"2023-06-06T12:20:54.000Z","dependencies_parsed_at":"2024-08-26T17:03:58.715Z","dependency_job_id":"98c134a0-b48b-4fbd-8e50-2779091523db","html_url":"https://github.com/TheCoder777/k8sready-springboot","commit_stats":null,"previous_names":["thecoder777/k8sready-springboot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCoder777%2Fk8sready-springboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCoder777%2Fk8sready-springboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCoder777%2Fk8sready-springboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCoder777%2Fk8sready-springboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheCoder777","download_url":"https://codeload.github.com/TheCoder777/k8sready-springboot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243030785,"owners_count":20224665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-17T06:28:16.026Z","updated_at":"2026-04-16T15:04:25.281Z","avatar_url":"https://github.com/TheCoder777.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# k8s ready Springboot template\n\nThis template is a preconfigured, scalable Springboot project with one minimal initial controller, ready to be\ndeployed to Kubernetes.\nA single Gradle task outputs a finalised docker image that can be directly uploaded to an image registry of your choice.\nThe image can directly be deployed with the preconfigured Deployment, Service and Ingress in\nthe [k8sready-springboot.yaml](./k8sready-springboot.yaml) file.\n\nThis was tested with a [kind cluster](https://kind.sigs.k8s.io) for simplicity's sake. Kind is\na [CNCF certified](https://landscape.cncf.io/?selected=kind) compliant Kubernetes installer.\nWith some additional GitHub actions for example, this will perfectly integrate with many pipelines.\n\n## Features\n\n### Compilation Process\n\nThis Template provides a 'double stage docker image-creation' process.\nThe final image is compiled in a clean Docker gradle environment during stage one of the [Dockerfile](./Dockerfile).\nIn the second stage, the clean java-executable is copied to an OpenJDK 17 container.\nThat Container can e.g. be Deployed on a Kubernetes environment,\nor you can do basically anything else you can do with a container these days.\n\n### Gradle\n\nAll local tasks are grouped by the `spring local` group.\nKubernetes related tasks are grouped by the `k8s` group\n\nThis template defines gradle commands for:\n- Development runs: `runSpringDev`\n- production runs: `runSpringProd`\n- testing runs: `testSpring`\n- Full Docker build: `buildDockerImage`\n\nWith the provided tasks, you can easily build a task to deploy directly to your own k8s.\n\n### Kubernetes\n\nAlso provided is a preconfigured Service, an Ingress and a Deployment to get you started.\nIf you're using OpenShift for example you will need to replace the Ingress component with a Route, but you probably know that.\n\n### Database\nYou can add your Production Database in [application.properties](./src/main/resources/application.properties) since that configuration will apply to production use.\nAn extra database for testing can go into [application-test.properties](./src/main/resources/application-test.properties).\nOne for development into [application-dev.properties](./src/main/resources/application-dev.properties)\n\n### Testing\nSince springboot provides us with a variety of tests [illustrated here](https://spring.io/guides/gs/testing-web/)\nI decided to provide some examples of `HttpRequestTest` and `HttpRequestMockTest` under [./src/test](./src/test/java/com/thecoder777/k8sreadyspringboot).\n\n### Env dependant values\nIn [application.properties](./src/main/resources/application.properties),\nI added an example `value.depending.on.environment` of a configuration value that holds different values per environment.\nAn example of how you use that in Java is provided in the main spring class [SpringKubernetesApplication](./src/main/java/com/thecoder777/k8sreadyspringboot/SpringKubernetesApplication.java)\nusing the `@Value` and `@PostConstruct` decorators.\nIf you don't like it, you can just remove it entirely from the two mentioned locations.\n\n### tl;dr features\n\n- Double Stage Docker image creation \n- Compiled in an extra gradle container as Stage 1\n- clean java-executable in OpenJDK 17 container as Stage 2\n- Gradle commands for development, production \u0026 testing\n- Preconfigured Service, Ingress and Deployment for Kubernetes (adapt the ingress for openshift)\n- Custom Testing database if needed\n- Predefined example tests illustrating different testing techniques (HttpRequestTest, HttpRequestMockTest)\n- Environment dependant values\n\n## Usage\n\nThis part is very straightforward:\n\n- Replace the name `k8sreadyspringboot` everywhere\n- Adapt the `value.depending.on.environment` under [application.properties](./src/main/resources/application.properties)\n- Run your first gradle command, for example `gradle runSpringProd` (that's locally)\n- Continue with the template as you like\n- Don't forget to read the Pitfalls first\n\n## Pitfalls\n\n1. Version number needs to be changed in 3 files: (commented)\n    - [build.gradle](./build.gradle) `version` attribute\n    - [Dockerfile](./Dockerfile) `ARTIFACT_NAME` variable\n    - [Kubernetes Yaml](./k8sready-springboot.yaml) in Deployment\n\n2. Server Port needs to be changed in 3 Locations: (commented)\n    - [default application.properties](./src/main/resources/application.properties) `server.port` attribute\n    - [Kubernetes Yaml](./k8sready-springboot.yaml) in Service and Ingress\n    - [Dockerfile](./Dockerfile) under `Expose`\n\n## License\n\nThe project is licensed under the [MIT license](./LICENSE).\n\n\n## Maintainer\n\nCurrent maintainer and owner: [TheCoder777](https://github.com/thecoder777)\n\n**Cheers!**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecoder777%2Fk8sready-springboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecoder777%2Fk8sready-springboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecoder777%2Fk8sready-springboot/lists"}