Eclipse JKube projesinin yarattaığı bir plugin. YAML dosyaları da oluşturabiliyor
Açıklaması şöyle
Goal Name Descriptionk8s:build Containerize your application into an imagek8s:push Push the Image built to a container registryk8s:resource Generate Kubernetes Manifestsk8s:deploy Apply these manifests on top of Kubernetesk8s:log View logs of your application running in Kubernetes Clusterk8s:debug Debug your application running into Kubernetes
build
Docker image yapılandırır
Örnek
Şöyle yaparız
mvn k8s:build# If docker daemon is not available mvn k8s:build -Djkube.build.strategy=jib
push
Docker image Remote Docker Repository'e gönderilir Açıklaması şöyle
To have Kubernetes Maven plugin push our built image to Docker Hub, we need to supply the image name to the Kubernetes Maven plugin, by adding jkube.generator.name property in pom.xml ...By doing so, the Kubernetes Maven plugin will get the image name from spring-boot.build-image.imageName property.By default, the Kubernetes Maven plugin always pushes images tagged as the latest to the remote repository. Since our built image is tagged with version rather than latest, we will need to disable this feature. Add the following jkube.skip.tag property with true value to pom.xml to disable Kubernetes Maven plugin overriding our tag in the supplied image name.
Örnek
Şöyle yaparız
<properties> <java.version>11</java.version> <spring-boot.build-image.imageName>andylke/${project.artifactId}:${project.version}</spring-boot.build-image.imageName> <jkube.generator.name>${spring-boot.build-image.imageName}</jkube.generator.name> <jkube.skip.tag>true</jkube.skip.tag> </properties>
Şöyle yaparız
mvnw ^ -Djkube.docker.username={docker-hub.username} ^ -Djkube.docker.password={docker-hub.password} ^ k8s:push
Örnek
plugin şöyle olsun
<plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>kubernetes-maven-plugin</artifactId> <version>${jkube.version}</version> <configuration> <images> <image> <name>quay.io/rohankanojia/helloapp:${project.version}</name> <alias>hello-world</alias> <build> <from>openjdk:latest</from> <cmd>java -jar maven/${project.artifactId}-${project.version}.jar</cmd> </build> </image> </images> </configuration> </plugin>
Şöyle yaparız
mvn k8s:push mvn k8s:push -Djkube.build.strategy=jib
resource
Açıklaması şöyle
Kubernetes Maven plugin can either generate1. based on opinionated defaults,2. based on the configuration provided in XML config3. resource templates in src/main/jkube directory.
Açıklaması şöyle
By default, Kubernetes Maven plugin generates a Deployment with a single replica and Service resource that is only reachable from within the cluster, known as ClusterIP. To create a network load balancer service with an externally accessible IP address, we need to change the default Service type to LoadBalancer. Add a jkube.enricher.jkube-service.type property with value LoadBalancer as follows.<jkube.enricher.jkube-service.type>LoadBalancer</jkube.enricher.jkube-service.type>Run the following command to invoke the Kubernetes Maven plugin to generate Kubernetes manifests.mvnw k8s:resource
Açıklaması şöyle
These Kubernetes manifests are all generated in target/classes/META-INF/jkube/kubernetes directory. You should find your generated jkube-app-deployment.yml and jkube-app-service.yml files
Örnek
Şöyle yaparız. Kubernetes yaml dosyalarını oluşturur
mvn k8s:resource
apply
Açıklaması şöyle
Kubernetes Maven plugin will combine all generated Kubernetes manifests from the target/classes/META-INF/jkube/kubernetes directory into a single Kubernetes manifest file, target/classes/META-INF/jkube/kubernetes.yml. This consolidated Kubernetes manifest will be used when we invoke the apply goal in Kubernetes Maven plugin.Run the following command to apply our generated Kubernetes manifest to our locally connected Kubernetes cluster.mvnw k8s:applyYour Kubernetes manifest being applied successfully to the Kubernetes cluster does not guarantee the defined Kubernetes resources will start successfully. Always verify the state of your applied resources.Run the following command to list all resources in your local Kubernetes cluster with labels app=jkube-app.kubectl get all -l app=jkube-appIf all goes well, you should have a running Pod, a service with an external IP address, a deployment, and ReplicaSet.
deploy
Şöyle yaparız. Kubernetes'te çalıştırır
mvn k8s:deploy mvn k8s:undeploy # Inspect logs mvn k8s:log mvn k8s:log -Djkube.log.follow=false
debug
Şöyle yaparız. Kubernetes'te debug için çalıştırır
mvn k8s:debug mvn k8s:debug -Djkube.debug.port=8000
remote-dev
Örnek
plugin şöyle olsun
<plugin><groupId>org.eclipse.jkube</groupId><artifactId>kubernetes-maven-plugin</artifactId><version>${jkube.version}</version><configuration><remoteDevelopment><remoteServices><remoteService><hostname>service1</hostname> <!-- Name of Service --><port>8080</port> <!-- Service port --><localPort>8081</localPort> <!-- Local Port where to expose --></remoteService><remoteService><hostname>service2</hostname> <!-- Name of Service --><port>8080</port> <!-- Service Port --><localPort>8082</localPort> <!-- Local Port where to expose --></remoteService></remoteServices></remoteDevelopment></configuration></plugin>
Şöyle yaparız. Böylece kubernetes ortamında çalışan 2 tane service deploy edilir. Servisler localhost 8081 ve 8082 portları ile erişilebilir
mvn k8s:remote-dev
Hiç yorum yok:
Yorum Gönder