All Downloads are FREE. Search and download functionalities are using the official Maven repository.

guides.oke.adoc Maven / Gradle / Ivy

There is a newer version: 4.1.1
Show newest version
///////////////////////////////////////////////////////////////////////////////

    Copyright (c) 2018, 2023 Oracle and/or its affiliates.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= Deploying to OKE
:description: Helidon Oracle Container Engine for Kubernetes (OKE) Guide
:keywords: helidon, guide, oracle, kubernetes
:rootdir: {docdir}/..

include::{rootdir}/includes/attributes.adoc[]

Push a Docker image of your Helidon application to Oracle Cloud Infrastructure
 Registry (OCIR), and deploy the image from the registry to Oracle Cloud
 Infrastructure Container Engine for Kubernetes (OKE).

== What You Need

|===
|About 10 minutes
| xref:{rootdir}/about/prerequisites.adoc[Helidon prerequisites]
|An OKE cluster. See the link:http://www.oracle.com/webfolder/technetwork/tutorials/obe/oci/oke-full/index.html[OKE documentation].
|A Helidon project created from the quickstart Maven archetype. See
 xref:{rootdir}/se/guides/quickstart.adoc[quickstart Maven archetype].
|===

== Push Your Image to OCIR

Your account must be in the `Administrators` group or another group that has
 the `REPOSITORY_CREATE` permission.

Sign in to the Oracle Cloud Infrastructure (OCI) web console and generate an
 authentication token. See link:https://docs.cloud.oracle.com/iaas/Content/Registry/Tasks/registrygettingauthtoken.htm[Getting an Auth Token].

NOTE: Remember to copy the generated token. You won't be able to access it
 again.

[source,bash]
.Log in to the OCIR Docker registry:
----
docker login \
       -u  \ # <1>
       -p  \ # <2>
       .ocir.io # <3>
----
<1> The user name in the format `/`.
<2> The password is the generated token.
<3> `` is the code for the OCI region that you're using. For
 example, the region code for Phoenix is `phx`. See
 link:https://docs.cloud.oracle.com/iaas/Content/General/Concepts/regions.htm[Regions and Availability Domains].

[source,bash]
.Tag the image that you want to push to the registry:
----
docker tag \
       helidon-quickstart-se:latest \ # <1>
       .ocir.io///: # <2>
----
<1> the local image to tag
<2> `` is optional. It is the name of a repository to which you want
 to push the image (for example, `project01`).

[source,bash]
.Push the image to the Registry:
----
docker push \
    .ocir.io///:
----

You can pull your image with the image path used above, for example:
 `phx.ocir.io/helidon/example/helidon-quickstart-se:latest`

== Setup your K8s Cluster

Create a namespace (for example, `helidon`) for the project:

[source,bash]
kubectl create namespace helidon

The repository that you created is private. To allow Kubernetes to
 authenticate with the container registry and pull the private image, you must
 create and use an image-pull secret.

[source,bash]
.Create an image-pull secret:
----
kubectl create secret docker-registry \
    ocirsecret \ # <1>
    --docker-server=.ocir.io \ # <2>
    --docker-username='/' \ # <3>
    --docker-password='' \ # <4>
    --docker-email='' \
    --namespace helidon # <5>
----
<1> The name of the config secret
<2> The docker registry (see docker tag step above)
<3> The user name (see docker login step above)
<4> The password (see docker login step above)
<5> The namespace created in the previous step

=== Deploy the Image to Kubernetes

First, change to the `helidon-quickstart-se` directory.

Then edit `app.yaml` and add the following under `spec` in the `deployment`
 section:

[source, yaml]
----
spec:
  imagePullSecrets:
  - name: ocirsecret # <1>
  containers:
  - name: helidon-quickstart-se
    image: phx.ocir.io/helidon/example/helidon-quickstart-se:latest # <2>
    imagePullPolicy: Always
    ports:
    - containerPort: 8080
----
<1> The config secret name
<2> The image path

[source,bash]
.Deploy the application:
----
kubectl create -f app.yaml -n helidon
----

[source,bash]
.Get the `NodePort` number for your new pod:
----
kubectl get svc -n helidon
----

[source,bash]
.Get the IP address for your cluster nodes:
----
kubectl get nodes
----

You can now access the application at `\http://:/greet`.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy