Skip to content

Releases: daggerok/k8s-ingress-explained

step: 1

24 Nov 05:42
Compare
Choose a tag to compare

k8s nginx-ingress Build Status

Reverse-proxy by nginx-ingress for spring-boot services in k8s with skaffold

table of content

  1. version: 0.0.1
  2. version: 0.0.2
  3. resources

Status: IN PROGRESS

features

local

local hello-variants-service

./mvnw -f hello-variants-service clean spring-boot:run &
http :8001/api/hello/find-all-hello
http post :8001/actuator/shutdown

local greeting-service

./mvnw -f greeting-service clean spring-boot:run &
http :8003/api/greeting/find-all-greetings
http :8003/api/greeting/find-all-greetings/max
http post :8003/actuator/shutdown

local frontend

./mvnw -f frontend clean spring-boot:run &
http :8004/api/greeting/find-all-hello
http :8004/api/greeting/find-all-greetings
http :8004/api/greeting/find-all-greetings/max
http post :8004/actuator/shutdown

GIB

requires: Docker

  • Add Google jib maven plugin in pom.xml file for spring-boot all applications / services

fat jar configuration

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>${jib-maven-plugin.version}</version>
    <configuration>
        <containerizingMode>packaged</containerizingMode>
        <container>
            <appRoot>/tmp</appRoot>
            <useCurrentTimestamp>true</useCurrentTimestamp>
            <entrypoint>
                <shell>bash</shell>
                <option>-c</option>
                <arg>java -cp /tmp/classpath:/tmp/*.jar</arg>
            </entrypoint>
            <args>
                <arg>/bin/bash</arg>
            </args>
        </container>
        <from>
            <image>openjdk:11.0.5-jre-stretch</image>
        </from>
        <to>
            <image>daggerok/${project.parent.artifactId}-${project.artifactId}</image>
            <tags>
                <tag>${project.version}</tag>
                <tag>latest</tag>
            </tags>
        </to>
    </configuration>
</plugin>

thin jar configuration

<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>${jib-maven-plugin.version}</version>
    <configuration>
        <allowInsecureRegistries>true</allowInsecureRegistries>
        <container>
            <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
        </container>
        <to>
            <image>daggerok/${project.parent.artifactId}-${project.artifactId}</image>
            <tags>
                <tag>${project.version}</tag>
                <tag>latest</tag>
            </tags>
        </to>
    </configuration>
</plugin>

debug jib

make sure you are using:

<from>
    <!--<image>gcr.io/distroless/java:11</image>-->
    <image>gcr.io/distroless/java:11-debug</image>
</from>

then build jib image and run command:

docker run -it \
    --entrypoint /busybox/sh \
    --network docker_k8s-nginx-ingress-example \
    daggerok/k8s-nginx-ingress-example-frontend:latest

fabric8

fabric8 configuration

<plugin>
    <groupId>io.fabric8</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>${docker-maven-plugin.version}</version>
    <configuration>
        <follow>false</follow>
        <verbose>true</verbose>
        <useColor>true</useColor>
        <logDate>default</logDate>
        <autoPull>always</autoPull>
        <keepRunning>false</keepRunning>
        <watchInterval>500</watchInterval>
        <allContainers>true</allContainers>
        <removeVolumes>true</removeVolumes>
        <imagePullPolicy>IfNotPresent</imagePullPolicy>
        <autoCreateCustomNetworks>true</autoCreateCustomNetworks>
        <images>
            <image>
                <alias>frontend</alias>
                <external>
                    <type>compose</type>
                    <basedir>src/main/docker</basedir>
                    <composeFile>docker-compose.yml</composeFile>
                </external>
                <run>
                    <wait>
                        <http>
                            <url>http://127.0.0.1:8004/find-all-greetings/ready</url>
                            <method>GET</method>
                            <status>200</status>
                        </http>
                        <time>100000</time>
                    </wait>
                </run>
            </image>
        </images>
    </configuration>
</plugin>

run with fabric8

build jib docker images and run everything using fabric8 maven docker-compose

./mvnw clean package jib:dockerBuild
./mvnw -f docker-compose -Pstart
http :8004/find-all-hello
http :8004/find-all-greetings
./mvnw -f docker-compose -Pstop

dkanejs docker-compose-maven-plugin

dkanejs configuration

<plugin>
    <groupId>com.dkanejs.maven.plugins</groupId>
    <artifactId>docker-compose-maven-plugin</artifactId>
    <version>${docker-compose-maven-plugin.version}</version>
    <configuration>
        <detail>true</detail>
        <verbose>false</verbose>
        <detachedMode>true</detachedMode>
        <ignorePullFailures>true</ignorePullFailures>
        <removeImagesType>local</removeImagesType>
        <removeImages>true</removeImages>
        <removeOrphans>true</removeOrphans>
        <removeVolumes>true</removeVolumes>
        <composeFile>${project.basedir}/src/main/docker/docker-compose.yaml</composeFile>
    </configuration>
</plugin>

run using dkanejs docker-compose-maven-plugin

build jib docker images and run everything using dkanejs docker-compose-maven-plugin

./mvnw clean package jib:dockerBuild
./mvnw -f docker-compose -Pup
http :8004/find-all-hello
http :8004/find-all-greetings
./mvnw -f docker-compose -Pdown

release

./mvnw release:clean release:prepare release:perform --batch-mode
# ./mvnw release:rollback

resources

step: 0

24 Nov 05:41
Compare
Choose a tag to compare

k8s nginx-ingress Build Status

Reverse-proxy by nginx-ingress for spring-boot services in k8s with skaffold

table of content

Status: IN PROGRESS

features

local

local hello-variants-service

./mvnw -f hello-variants-service clean spring-boot:run &
http :8001/api/hello/find-all-hello
http post :8001/actuator/shutdown

local greeting-service

./mvnw -f greeting-service clean spring-boot:run &
http :8003/api/greeting/find-all-greetings
http :8003/api/greeting/find-all-greetings/max
http post :8003/actuator/shutdown

local frontend

./mvnw -f frontend clean spring-boot:run &
http :8004/api/greeting/find-all-hello
http :8004/api/greeting/find-all-greetings
http :8004/api/greeting/find-all-greetings/max
http post :8004/actuator/shutdown

release

./mvnw release:clean release:prepare release:perform --batch-mode
# ./mvnw release:rollback

resources