-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(quickstarts): improved hello-world example
Removed declared exception in ResourceMojo.extractEnricherConfig that is never thrown #2780 Signed-off-by: wayne kirimi <[email protected]> --- chore(example): Added /hello endpoint that prints a message Signed-off-by: wayne kirimi <[email protected]> --- chore(example): Removed declarations of thrown exceptions Signed-off-by: wayne kirimi <[email protected]> --- chore(example): Updated image name Signed-off-by: wayne kirimi <[email protected]> --- chore(example): Updated quickstart readme Signed-off-by: wayne kirimi <[email protected]> --- chore(example): Updated quickstart with requested changes Signed-off-by: wayne kirimi <[email protected]> --- chore(example): Updated project Readme Signed-off-by: wayne kirimi <[email protected]> --- chore(example): Refactored a child class. Signed-off-by: wayne kirimi <[email protected]> --- Merge branch 'master' into improve-example-2788 --- fix/quickstart-example: Fixed requested changes. Signed-off-by:wayne kirimi <[email protected]> --- Update RootHandler.java --- Readme changes for Hello-World quickstart --- Readme change --- review: fix hello-world quickstart
- Loading branch information
1 parent
78a7989
commit ea0085f
Showing
5 changed files
with
129 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,11 @@ $ git clone [email protected]:eclipse/jkube.git | |
# 2. Move to Hello World Quickstart folder | ||
$ cd jkube/quickstarts/maven/hello-world | ||
|
||
# 3. Build Project and run JKube goals | ||
# 3. Configure your local environment to re-use the Docker daemon inside the Minikube instance. | ||
|
||
~ jkube/quickstarts/maven/hello-world : $ eval $(minikube -p minikube docker-env) | ||
|
||
# 4. Build Project and run JKube goals | ||
$ mvn clean install \ | ||
k8s:build `# Build Docker Image` \ | ||
k8s:resource `# Generate Kubernetes Manifests` \ | ||
|
@@ -150,26 +154,21 @@ $ mvn clean install \ | |
```shell script | ||
# Using Kubectl | ||
$ kubectl get pods | ||
NAME READY STATUS RESTARTS AGE | ||
helloworld-7c4665f464-xwskj 0/1 Completed 2 27s | ||
$ kubectl logs jkube-sample-helloworld-7c4665f464-xwskj | ||
Hello World! | ||
# Using JKube | ||
$ mvn k8s:log | ||
[INFO] k8s: [NEW] helloworld-7c4665f464-xwskj status: Running | ||
[INFO] k8s: [NEW] Tailing log of pod: helloworld-587dfff745-2kdpq | ||
[INFO] k8s: [NEW] Press Ctrl-C to stop tailing the log | ||
[INFO] k8s: [NEW] | ||
[INFO] k8s: Hello World! | ||
[INFO] k8s: [NEW] helloworld-7c4665f464-xwskj status: Running | ||
NAME READY STATUS RESTARTS AGE | ||
helloworld-664bf5fdff-2bmrt 1/1 Running 0 9s | ||
$ kubectl get svc | ||
helloworld NodePort 10.110.92.145 <none> 8080:32353/TCP 58m | ||
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 7h | ||
$ curl `minikube ip`:32353/hello | ||
Hello World | ||
``` | ||
|
||
#### Troubleshooting | ||
|
||
If you experience problems using minikube that pod's status shows 'ImagePullBackOff' and not 'Completed' you must share the minikube's docker daemon environment with your shell with: | ||
If you experience problems using minikube that pod's status shows 'ImagePullBackOff' and not 'Running' you must share the minikube's docker daemon environment with your shell with: | ||
|
||
```shell script | ||
$ eval $(minikube docker-env) | ||
$ eval $(minikube -p minikube docker-env) | ||
``` | ||
|
||
You can remove this from your shell again with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...arts/maven/hello-world/src/main/java/org/eclipse/jkube/sample/helloworld/RootHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.sample.helloworld; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.logging.Logger; | ||
import java.util.logging.Level; | ||
|
||
import com.sun.net.httpserver.HttpExchange; | ||
import com.sun.net.httpserver.HttpHandler; | ||
|
||
/** | ||
* @author: Wayne Kirimi | ||
*/ | ||
public class RootHandler implements HttpHandler { | ||
|
||
private static final Logger log = Logger.getLogger(App.class.getSimpleName()); | ||
|
||
@Override | ||
public void handle(HttpExchange exchange) { | ||
try (OutputStream outputStream = exchange.getResponseBody()) { | ||
log.info("GET /hello"); | ||
String response = "Hello World"; | ||
exchange.sendResponseHeaders(200, response.length()); | ||
exchange.getResponseHeaders().set("Content-Type", "text/plain"); | ||
outputStream.write(response.getBytes()); | ||
log.info("Response written successfully: " + response); | ||
} catch (IOException e) { | ||
log.severe("Server failed to respond: " + e.getMessage()); | ||
} | ||
} | ||
} |