From cb44cc3c62a4688098985be58357d7f591ec8154 Mon Sep 17 00:00:00 2001 From: sreejith-rajashekaran Date: Tue, 7 Jan 2025 14:40:16 +0530 Subject: [PATCH 1/4] Updated the Trait to Gateway Signed-off-by: sreejith-rajashekaran --- 01.Helloworld/README.md | 105 ++++++++++++++++++++++----------- 01.Helloworld/app.yaml | 7 ++- 01.Helloworld/kind-config.yaml | 7 +++ 3 files changed, 80 insertions(+), 39 deletions(-) create mode 100644 01.Helloworld/kind-config.yaml diff --git a/01.Helloworld/README.md b/01.Helloworld/README.md index bed3b56..83090a6 100644 --- a/01.Helloworld/README.md +++ b/01.Helloworld/README.md @@ -28,19 +28,25 @@ get all the files mentioned here in the [app](./app) folder. 3. Create a file named `Dockerfile` and copy the code from [`app/Dockerfile`](./app/Dockerfile), See [official Python docker image](https://hub.docker.com/_/python/) for more details. -4. Use Docker to build the sample code into a container. To build and push with +4. Login to your Docker Hub account, using the below command. + ```shell script + docker login + ``` + This would direct you to click enter and it would open up a browser. Login to your Docker Hub account on the browser and the control would come back to CLI. You would get a success message if login was completed. +5. Use Docker to build the sample code into a container. To build and push with Docker Hub, run these commands replacing `oamdev` with your Docker Hub username ```shell script # Build the container on your local machine -docker build -t oamdev/helloworld-python:v1 . +docker_hub_username = +docker build -t $docker_hub_username/helloworld-python:v1 . # Push the container to docker registry -docker push oamdev/helloworld-python:v1 +docker push $docker_hub_username/helloworld-python:v1 ``` -Now we have a docker image tagged `oamdev/helloworld-python:v1`. +Now we have a docker image tagged ` Again, as an end-user, you are also supposed to know how to check the traits > already installed on the platform and the usage of each. @@ -190,20 +191,19 @@ vela show webservice Check the configurable points (properties) of a trait ```shell -vela show ingress +vela show gateway ```
-click to show properties of ingress trait +click to show properties of gateway trait ```console # Properties -+--------+------------------------------------------------------------------------------+----------------+----------+---------+ -| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT | -+--------+------------------------------------------------------------------------------+----------------+----------+---------+ -| http | Specify the mapping relationship between the http path and the workload port | map[string]int | true | | -| domain | Specify the domain you want to expose | string | true | | -+--------+------------------------------------------------------------------------------+----------------+----------+---------+ ++---------------------+------------------------------------------------------------------------------------------------------+-------------------------------------------------+----------+------------------------+ +| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT | ++---------------------+------------------------------------------------------------------------------------------------------+-------------------------------------------------+----------+------------------------+ +| domain | Specify the domain you want to expose. | string | false | | +| http | Specify the mapping relationship between the http path and the workload port. | map[string]int | true | | ```
@@ -222,23 +222,53 @@ spec: - name: helloworld type: webservice # <=== component type properties: # <=== component properties - image: oamdev/helloworld-python:v1 + image: /helloworld-python:v1 env: - name: "TARGET" value: "KubeVela" port: 8080 traits: - - type: ingress # <=== trait type + - type: gateway # <=== trait type properties: # <=== trait properties domain: localhost http: /: 8080 ``` -Let's save it as file `app.yaml` and apply to deploy. +Update the above code with your docker username and save it as file `app.yaml`. +Use the Vela command to apply. + +```shell script + vela up -f app.yaml --publish-version v1.1.0 +``` + +You will get a success message as mentioned below. + +```console +Applying an application in vela K8s object format... +✅ App has been deployed 🚀🚀🚀 + Port forward: vela port-forward first-app -n prod + SSH: vela exec first-app -n prod + Logging: vela logs first-app -n prod + App status: vela status first-app -n prod + Endpoint: vela status first-app -n prod --endpoint +Application prod/first-app applied. +``` + +You can check the end point using the command ```shell script -kubectl apply -f app.yaml +vela status first-app --endpoint +``` +The output would like the below + +```console ++---------+------------+--------------------------+-----------------------------+-------+ +| CLUSTER | COMPONENT | REF(KIND/NAMESPACE/NAME) | ENDPOINT | INNER | ++---------+------------+--------------------------+-----------------------------+-------+ +| local | helloworld | Ingress/prod/helloworld | http://localhost | false | +| local | helloworld | Service/prod/helloworld | http://helloworld.prod:8080 | true | ++---------+------------+--------------------------+-----------------------------+-------+ ``` ## Verify @@ -250,8 +280,8 @@ vela ls ``` ```console -APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME -first-app helloworld webservice ingress running healthy 2021-05-18 15:40:02 +0900 KST +APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME +first-app helloworld webservice gateway running healthy Ready:1/1 2025-01-06 22:42:28 +0530 IST ``` And call the service by cURL tool @@ -266,7 +296,6 @@ Hello KubeVela! Yeah, we have successfully deploy an application from source now. -> :warning: ingress trait replies on the ingress controller, such as nginx-ingress, installed in your cluster. > If you cannot access the domain, you may check the network or ingress > configuration of your cluster. @@ -299,9 +328,13 @@ if __name__ == "__main__": Build and create image with a new tag. ```shell script -docker build -t oamdev/helloworld-python:v2 . -docker push oamdev/helloworld-python:v2 -``` +# Build the container on your local machine +docker_hub_username = +docker build -t $docker_hub_username/helloworld-python:v1 . + +# Push the container to docker registry +docker push $docker_hub_username/helloworld-python:v1 +``` ### Change the component properties @@ -323,7 +356,7 @@ spec: value: "KubeVela" port: 8080 traits: - - type: ingress + - type: gateway properties: domain: localhost http: @@ -332,8 +365,8 @@ spec: Apply the upgraded application -```console -kubectl apply -f app-upgrade.yaml +```shell script + vela up -f app.yaml --publish-version v1.1.1 ``` ### Verify diff --git a/01.Helloworld/app.yaml b/01.Helloworld/app.yaml index ebc3251..af7d9d8 100644 --- a/01.Helloworld/app.yaml +++ b/01.Helloworld/app.yaml @@ -7,14 +7,15 @@ spec: - name: helloworld type: webservice properties: - image: oamdev/helloworld-python:v1 + image: /helloworld-python:v1 env: - name: "TARGET" value: "KubeVela" port: 8080 traits: - - type: ingress + - type: gateway properties: domain: localhost http: - /: 8080 + - path: "/" + port: 8080 diff --git a/01.Helloworld/kind-config.yaml b/01.Helloworld/kind-config.yaml new file mode 100644 index 0000000..d27d90c --- /dev/null +++ b/01.Helloworld/kind-config.yaml @@ -0,0 +1,7 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + extraMounts: + - hostPath: /Users/srajashekaran/Desktop/ZscalerRootCertificate-2048-SHA256.crt + containerPath: /etc/ssl/certs/zscaler.crt From c8f9ec18fe8dab91da25790aadb39604f7ef1c32 Mon Sep 17 00:00:00 2001 From: sreejith-rajashekaran Date: Tue, 7 Jan 2025 15:07:49 +0530 Subject: [PATCH 2/4] Updated the Trait to Gateway Signed-off-by: sreejith-rajashekaran --- 01.Helloworld/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/01.Helloworld/README.md b/01.Helloworld/README.md index 83090a6..1b3fa9b 100644 --- a/01.Helloworld/README.md +++ b/01.Helloworld/README.md @@ -34,8 +34,7 @@ get all the files mentioned here in the [app](./app) folder. ``` This would direct you to click enter and it would open up a browser. Login to your Docker Hub account on the browser and the control would come back to CLI. You would get a success message if login was completed. 5. Use Docker to build the sample code into a container. To build and push with - Docker Hub, run these commands replacing `oamdev` with your Docker Hub - username + Docker Hub, run these commands after updating your Docker Hub Username. ```shell script # Build the container on your local machine @@ -46,7 +45,7 @@ docker build -t $docker_hub_username/helloworld-python:v1 . docker push $docker_hub_username/helloworld-python:v1 ``` -Now we have a docker image tagged `/helloworld-python:v1`. ## Determine Component Type From 56224439988de310e9888cc1401c89ef31fd590f Mon Sep 17 00:00:00 2001 From: sreejith-rajashekaran Date: Mon, 20 Jan 2025 12:00:41 +0530 Subject: [PATCH 3/4] Updated the Trait to Gateway for sample 2 Signed-off-by: sreejith-rajashekaran --- 02.ServiceTracker_App/KubeVelaManifest/app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02.ServiceTracker_App/KubeVelaManifest/app.yaml b/02.ServiceTracker_App/KubeVelaManifest/app.yaml index 520bf6c..053a4e5 100644 --- a/02.ServiceTracker_App/KubeVelaManifest/app.yaml +++ b/02.ServiceTracker_App/KubeVelaManifest/app.yaml @@ -17,7 +17,7 @@ spec: - name: QUAKES_API_ROOT value: "http://quakes-api.default.svc.cluster.local:3012/" traits: - - type: ingress + - type: gateway properties: domain: localhost http: From 9bbbf025b5a753d0c3aaac24d716d4551af96360 Mon Sep 17 00:00:00 2001 From: sreejith-rajashekaran Date: Mon, 20 Jan 2025 16:58:20 +0530 Subject: [PATCH 4/4] Updated the Trait to Gateway for sample 3 Signed-off-by: sreejith-rajashekaran --- .../KubeVelaManifest/app.yaml | 2 +- 03.BikeSharing360_MultiContainer_App/README.md | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/03.BikeSharing360_MultiContainer_App/KubeVelaManifest/app.yaml b/03.BikeSharing360_MultiContainer_App/KubeVelaManifest/app.yaml index f300a1e..8dc5824 100644 --- a/03.BikeSharing360_MultiContainer_App/KubeVelaManifest/app.yaml +++ b/03.BikeSharing360_MultiContainer_App/KubeVelaManifest/app.yaml @@ -15,7 +15,7 @@ spec: - name: emailapi value: "http://bikesharing-email-api" traits: - - type: ingress + - type: gateway properties: domain: bikesharing.com http: diff --git a/03.BikeSharing360_MultiContainer_App/README.md b/03.BikeSharing360_MultiContainer_App/README.md index 798d9db..5ec1207 100644 --- a/03.BikeSharing360_MultiContainer_App/README.md +++ b/03.BikeSharing360_MultiContainer_App/README.md @@ -19,10 +19,6 @@ BikeSharing 360 for single containers can be found [installation](https://kubevela.io/docs/install) document to get KubeVela installed. -* Make sure that the ingress controller has been installed (instructions -[here](https://kubernetes.github.io/ingress-nginx/deploy)). - - ## Quickstart: Deploy the sample through KubeVela Deploy the application to Kubernetes cluster.