Skip to content

Commit

Permalink
chore (quickstarts/gradle) : Cleanup unnecessary files in daprhellowo…
Browse files Browse the repository at this point in the history
…rld quickstart

+ Remove unnecessary files
+ Add license headers
+ Correct typos

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Mar 24, 2023
1 parent 579707b commit 9cac97f
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 97 deletions.
37 changes: 0 additions & 37 deletions quickstarts/gradle/daprhelloworld/.gitignore

This file was deleted.

46 changes: 28 additions & 18 deletions quickstarts/gradle/daprhelloworld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ Kubernetes with the help of Kubernetes jkube Gradle Plugin.
## How to Build?
In order to build,you will need to install dapr in kubernetes

--Install dapr in kubernetes
- Install dapr in kubernetes

dapr init -k
```shell script
$ dapr init -k
```
- verify installation
```shell script
$ dapr status -k
```
- if required update installation

--verify installation

dapr status -k

--if required update installation

dapr upgrade -k --runtime-version=x.x.x
```shell script
$ dapr upgrade -k --runtime-version=x.x.x
```

## Deploying to Kubernetes
Kubernetes Gradle Plugin is already added to the project plugins section.
Expand All @@ -36,17 +39,24 @@ a Kubernetes cluster:

in order dapr application to work in kubernetes cluster it needs following annotation in deployment.yaml file under spec, template metadata section

```yaml
annotations:

dapr.io/enabled: "true"
dapr.io/enabled: "true"
dapr.io/app-id: "daprhelloworld"
dapr.io/app-port: "8085"
dapr.io/config: "appconfig"
```
dapr.io/app-id: "daprhelloworld"
dapr.io/app-port: "8085"
In order to deploy application, you need to run Kubernetes Gradle Plugin build, resource and apply goals:
dapr.io/config: "appconfig"
If you are working with slow internet connection then rediness and livebess probe may timeout uncomment timeout and delay related annotation from above
```shell script
# Kubernetes
$ gradle clean build k8sBuild k8sResource k8sApply
# OpenShift
$ gradle clean build ocBuild ocResource ocApply
```

If you are working with slow internet connection then readiness and liveness probe may timeout uncomment timeout and delay related annotation from above

If you need time obervability in your application you can use zipkin and dapr appconfig, installation instruction for zipkin with appconfig is given in zipkininstallation.txt
If you need time observability in your application you can use zipkin and dapr appconfig, installation instruction for zipkin with appconfig is given in zipkininstallation.sh

14 changes: 14 additions & 0 deletions quickstarts/gradle/daprhelloworld/appconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#
# 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
#

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
Expand Down
39 changes: 26 additions & 13 deletions quickstarts/gradle/daprhelloworld/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ plugins {
id 'org.springframework.boot' version '2.7.8'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id "io.freefair.lombok" version "6.6.1"
id 'org.eclipse.jkube.kubernetes' version '1.9.1'
id 'org.eclipse.jkube.kubernetes' version '1.11.0'
id 'org.eclipse.jkube.openshift' version '1.11.0'
}

group = 'com.example'
Expand All @@ -17,7 +18,6 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'io.dapr:dapr-sdk-springboot:1.7.1'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
Expand All @@ -26,17 +26,30 @@ tasks.named('test') {

kubernetes {
resources {
annotations {
pod = [
'dapr.io/enabled' : true,
'dapr.io/app-id' : "daprhelloworld",
'dapr.io/app-port' : "8085",
// if you want to trace application then please uncomment below and please also create appconfig.yaml and zipkin.yaml by following zipkininstallation.txt
// 'dapr.io/config' : "appconfig"
]
annotations {
pod = [
'dapr.io/enabled' : true,
'dapr.io/app-id' : "daprhelloworld",
'dapr.io/app-port' : "8085",
// if you want to trace application then please uncomment below and please also create appconfig.yaml and zipkin.yaml by following zipkininstallation.sh
// 'dapr.io/config' : "appconfig"
]
}
imagePullPolicy = "Always"
}
// namespace = 'default'
// replicas = "2"
}

openshift {
resources {
annotations {
pod = [
'dapr.io/enabled' : true,
'dapr.io/app-id' : "daprhelloworld",
'dapr.io/app-port' : "8085",
// if you want to trace application then please uncomment below and please also create appconfig.yaml and zipkin.yaml by following zipkininstallation.sh
// 'dapr.io/config' : "appconfig"
]
}
imagePullPolicy = "Always"
}
}
}
15 changes: 14 additions & 1 deletion quickstarts/gradle/daprhelloworld/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#
# 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
#

jkube.generator.registry = docker.io/vishalrijhwani
jkube.generator.name = docker.io/vishalrijhwani/%a:%l
jkube.image.name = daprhelloworld
jkube.generator.build.imagePullPolicy = Always
#jkube.enricher.jkube-namespace.namespace = default
jkube.enricher.jkube-controller.replicaCount = 1
jkube.enricher.jkube-service.type = LoadBalancer
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* 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 com.example.demo;

import org.springframework.boot.SpringApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* 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 com.example.demo.controller;

import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -11,7 +24,6 @@ public class HelloWorldController {

@GetMapping("/wish")
public String wish() {
log.info("within wish method");
return "Hello World";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
#
# 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
#

spring.application.name=daprhelloworld
server.port=8085

This file was deleted.

14 changes: 14 additions & 0 deletions quickstarts/gradle/daprhelloworld/zipkin.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#
# 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
#

apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
28 changes: 28 additions & 0 deletions quickstarts/gradle/daprhelloworld/zipkininstallation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# 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
#

# create name space usernamespace
kubectl create namespace usernamespace
# for installing zipkin use below command
kubectl -n usernamespace create -f zipkin.yaml
kubectl create -f zipkin.yaml
kubectl -n usernamespace create -f appconfig.yaml
kubectl create -f appconfig.yaml
# for zipkin uninstallation
kubectl -n usernamespace delete -f zipkin.yaml
kubectl delete -f zipkin.yaml
kubectl -n usernamespace delete -f appconfig.yaml
kubectl delete -f appconfig.yaml
# delete namespace
kubectl delete namespace usernamespace
14 changes: 0 additions & 14 deletions quickstarts/gradle/daprhelloworld/zipkininstallation.txt

This file was deleted.

0 comments on commit 9cac97f

Please sign in to comment.