Deploy an application from the Google Cloud Console Marketplace
This section details how to deploy an application to your Anthos GKE cluster on prem, using the Google Cloud Console.
Prerequisites
-
An Anthos cluster deployed on premises and registered with Google Cloud Console
-
A MetalLB load balancer configured in your Anthos cluster
-
An account with permissions to deploy applications to the cluster
-
A billing account with Google Cloud if you choose an application with associated costs (optional)
Deploying an application
For this use case, we deploy a simple WordPress application to one of our Anthos clusters using the Google Cloud Console. The deployment uses persistent storage provided by NetApp ONTAP in a predefined storageclass. We then demonstrate two different methods to modify the applications default service so that the MetalLB load balancer supplies it with an IP address and exposes it to the world.
To deploy an application in this manner, complete the following steps:
-
Verify that the cluster you want to deploy to is accessible in Google Cloud Console.
-
Select Applications from the left-side menu, select the three-dot option menu at the top, and select Deploy from Marketplace, which brings up a new window from which you can select an application from the Google Cloud Marketplace.
-
Search for the application you want to install, in this case WordPress.
-
After you select the WordPress application, an overview screen displays. Click the Configure button.
-
On the next page you must select the cluster to deploy to, in our case Demo-Cluster. Select or create a new namespace and application instance name, and select which storage classes and persistent volume sizes you need for both the WordPress application and its backing MariaDB database. In both cases, we chose the ONTAP-NAS-CSI storage class.
Do not select Enable public IP Access. Doing so creates a service of type NodePort that is not accessible from an on-premises Anthos deployment. -
After you click the Deploy button, you get a page providing application details. You can refresh this page or log into your cluster using the CLI to check the status of the deployment.
-
The CLI can be used to check the status of the application as it is being deployed by running the command to fetch pod info in our application namespace:
kubectl get pods -n anthos-wp
.Notice in this screenshot that there is a deployer pod in an error state. This is normal. This pod is a helper pod used by the Google Cloud Console to deploy the application that self-terminates after the other pods have begun their initialization process. -
After a few moments, verify that your application is running.
Exposing the application
After the application is deployed, you have two methods to assign it a world-reachable IP.
Using the Google Cloud Console
You can expose the application by using the Google Cloud Console and editing the YAML output for the services in a browser to set a publicly reachable IP. To do so, perform the following steps:
-
In the Google Cloud Console, click Services and Ingress in the left-side menu.
-
Click the
wordpress-wordpress-svc
service. This opens the Service Details screen. Click the Edit button at the top. -
The Editing Service Details page opens containing the YAML information for the service. Scroll down until you see the
spec:
section and thetype:
value, which is set toClusterIP
. Change this value toLoadBalancer
and click the Save button. -
When you return to the Service Details page, the
Type:
now listsLoadBalancer
and theExternal endpoints:
field lists an assigned IP address from the MetalLB pool and the port through which the application is accessible.
Patching the service with Kubectl
You can expose the application by using the CLI and the kubectl patch
command to modify your deployment and set a publicly reachable IP. To do so, complete the following steps:
-
List the services associated with the pods in your namespace with the
kubectl get services -n anthos-wp
command. -
Modify the service type from
ClusterIP
to typeLoadbalancer
using the following command:kubectl patch svc wordpress-wordpress-svc -p '{"spec": {"type": "LoadBalancer"}}' -n anthos-wp'.
This new service type is automatically assigned an available IP address from the MetalLB pool.
Visit the application at the exposed external IP
Now that you have the application exposed with a publicly reachable IP address, you can visit your WordPress instance using a browser.