You can create projects and applications in Kubernetes Application Navigator with the OpenShift console.
Ensure that you install an OpenShift environment with kAppNav installed. You need access to the console and also need to have a user account that is authorized to create projects and applications.
Many names, labels, and resources are defined and used by convention with Kubernetes. Depending on which development tools that you use, some names, labels, and resources can vary. Kubernetes Application Navigator relies on matching these names, labels, and resources to define and display your application. Because of this condition, you need to understand how your application is deployed, what resources are used, and how it is named and labeled. The exact names, labels, and resource kinds can vary based on your application and environment.
-
Log in to your OpenShift Console.
-
From the Service Catalog, create a new Node.js project.
-
Use the project creation dialog box to create a new project.
-
Create the Node.js application.
-
Close the dialog box and navigate to the newly created My Node Project.
-
Navigate to the My Node Project project view. If necessary, wait for the build to complete.
-
When the build is complete and the pod is deployed, access the URL of the application.
To display the application with Kubernetes Application Navigator, you can create an Application Custom Resource. You can create an Application Custom Resource by using either the kAppNav GUI or the kubectl CLI.
-
Go to the kAppNav UI and click the Create Applications button.
-
On the General tab, specify the application name and namespace.
-
On the Selectors tab, specify the app label name and the application name that appears under Value.
-
On the Kinds tab, specify two resource kinds in the resources group.
-
Click create.
-
Navigate into the my-node-app application to see the details and components that compose the application.
You can add more resources, such as Services and Routes, to the application components by editing the Application Custom Resource.
-
Navigate into the application. From the action menu, click Edit to modify the Application Custom Resource as a JSON file.
-
Add more Kinds to the componentKinds list and click Save.
-
Kubernetes Application Navigator automatically updates the display to show the added resources. The new resources might display as Unknown under Status for a few moments until the status changes to Normal.
Important: If you do not create the Application Custom Resource through the GUI before you create the Application Custom Resource through the CLI, the output of the steps might look different.
-
Optional: Use the following command to ensure that the pods in the
my-node-app
are running:kubectl get pods -n my-node-project
.# kubectl get pods -n my-node-project NAME READY STATUS RESTARTS AGE my-node-app-1-build 0/1 Completed 0 31m my-node-app-1-mlvgl 1/1 Running 0 31m
-
Create an Application Custom Resource YAML file.
- The YAML file describes the specific Kubernetes resources that are included in the Application that you define.
- Application Custom Resource YAML
my-node-app-cr.yaml
:
apiVersion: app.k8s.io/v1beta1 kind: Application metadata: name: my-node-app2 namespace: my-node-project spec: componentKinds: - group: resources kind: Pod - group: resources kind: DeploymentConfig selector: matchLabels: app: my-node-app
-
Create the
my-node-app-crd.yaml
file Application Custom Resource with the following command:kubectl apply -f my-node-app-cr.yaml
# kubectl apply -f my-node-app-crd.yaml application.app.k8s.io/my-node-app2 created
-
Confirm that the Application Custom Resource is created by using the following command:
kubectl get application -n my-node-project
- The
my-node-app
resource is created when you create the Application Custom Resource through the GUI.
# kubectl get application -n my-node-project NAME AGE my-node-app 48m my-node-app2 19m
- The
-
Navigate to Kubernetes Application Navigator to see the
my-node-app
andmy-node-app2
resources.
You can add more resources, such as Services
and Routes
, to the application components by editing the Application Custom Resource.
- Update the
my-node-app-cr.yaml
file to include theService
andRoute
apiVersion: app.k8s.io/v1beta1
kind: Application
metadata:
name: my-node-app2
namespace: my-node-project
spec:
componentKinds:
- group: resources
kind: Pod
- group: resources
kind: DeploymentConfig
- group: resources
kind: Service
- group: resources
kind: Route
selector:
matchLabels:
app: my-node-app
- Apply the updated my-node-app-cr.yaml file with the following command:
kubectl apply -f my-node-app-cr.yaml
- The Application Custom Resource is configured:
# kubectl apply -f my-node-app-cr.yaml
application.app.k8s.io/my-node-app2 configured