Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/antora.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name: hazelcast
version: 6.0-snapshot
name: templates
version: ~
1 change: 1 addition & 0 deletions docs/modules/ROOT/examples/platform-operator
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This workflow takes the contents of the branches/tags and builds the production documentation site
name: Build production site

on:
push:
branches: [main]

jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- name: Trigger build
run: curl -X POST -d {} https://api.netlify.com/build_hooks/6238ac2881e6d20c7db8e6c8
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
name: Test on GKE
on:
push:
paths-ignore:
- "docs/**"

env:
GCP_PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_ZONE: europe-west1-b
GCP_NETWORK: tutorial-test-network
EXAMPLES_DIR: docs/modules/ROOT/examples/operator-expose-externally

jobs:
create-gke-cluster:
name: Create GKE cluster
runs-on: ubuntu-latest
outputs:
CLUSTER_NAME: ${{ steps.cluster.outputs.CLUSTER_NAME }}

steps:
- name: Authenticate to GCP
uses: "google-github-actions/[email protected]"
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.GCP_PROJECT_ID }}

- name: Create GKE cluster
id: cluster
run: |-
CLUSTER_NAME="hpo-ex-ex-$GITHUB_RUN_NUMBER"
echo "CLUSTER_NAME=$CLUSTER_NAME" >> $GITHUB_ENV
echo "::set-output name=CLUSTER_NAME::${CLUSTER_NAME}"

gcloud container clusters create $CLUSTER_NAME \
--zone=${{ env.GKE_ZONE }} \
--project=${{ env.GCP_PROJECT_ID }} \
--network=${{ env.GCP_NETWORK }} \
--machine-type=n1-standard-2 \
--num-nodes=2
sleep 30

- name: Connect to the GKE cluster
run: |
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} \
--zone ${{ env.GKE_ZONE }} \
--project ${{ env.GCP_PROJECT_ID }}

- name: Install Kubectl
run: |-
gcloud components install kubectl

- name: Deploy operator
run: |-
helm repo add hazelcast https://hazelcast-charts.s3.amazonaws.com/
helm repo update
helm install operator hazelcast/hazelcast-platform-operator --set installCRDs=true,phoneHomeEnabled=false

run-tests:
name: Run Integration tests on GKE
runs-on: ubuntu-latest
needs: create-gke-cluster
env:
CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}

strategy:
max-parallel: 1
fail-fast: false
matrix:
include:
- type: smart
suffix: ""
- type: unisocket
suffix: "-unisocket"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 17
distribution: "adopt"
cache: "maven"

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "14"
cache: "npm"
cache-dependency-path: "**/package-lock.json"

- name: Set up Golang
uses: actions/setup-go@v2
with:
go-version: "^1.17.2"

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
cache: "pip"

- name: Authenticate to GCP
uses: "google-github-actions/[email protected]"
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.GCP_PROJECT_ID }}

- name: Install Kubectl
run: |-
gcloud components install kubectl

- name: Connect to the GKE cluster
run: |
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} \
--zone ${{ env.GKE_ZONE }} \
--project ${{ env.GCP_PROJECT_ID }}

- name: Deploy Hazelcast cluster
run: |-
kubectl apply -f $EXAMPLES_DIR/hazelcast${{matrix.suffix}}.yaml

- name: Waith for Hazelcast cluster to be ready
run: |-
kubectl wait --for='jsonpath={.status.phase}=Running' hazelcast/my-hazelcast${{matrix.suffix}} --timeout 300s

- name: Wait for external IP to get assigned
timeout-minutes: 5
run: |-
serviceType=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.spec.type}")
if [ "$serviceType" != "LoadBalancer" ]; then
exit 1
fi
EXTERNAL_IP=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
while [ "$EXTERNAL_IP" == "" ]; do
sleep 10
EXTERNAL_IP=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
done

echo "EXTERNAL_IP=${EXTERNAL_IP}" >> $GITHUB_ENV

- name: Wait for Smart type member IPs to get assigned
if: matrix.type == 'smart'
timeout-minutes: 5
run: |-
for i in {0..2}; do
SVC_NAME="my-hazelcast${{matrix.suffix}}-${i}"
SVC_EXTERNAL_IP=$(kubectl get svc "${SVC_NAME}" --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
while [ "$SVC_EXTERNAL_IP" == "" ]; do
sleep 10
SVC_EXTERNAL_IP=$(kubectl get svc "${SVC_NAME}" --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
done
done

- name: Test Java Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd $EXAMPLES_DIR/java${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" src/main/java/com/hazelcast/Main.java
mvn package
java -jar target/*jar-with-dependencies*.jar >> output-java.txt &
PID=$!
sleep 30
kill $PID

cat output-java.txt | grep 'Successful connection!' -q

- name: Test Node.js Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd $EXAMPLES_DIR/nodejs${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" client.js
npm install
npm start >> output-nodejs.txt &
PID=$!
sleep 30
kill $PID

cat output-nodejs.txt | grep 'Successful connection!' -q

- name: Test Go Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd $EXAMPLES_DIR/go${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" main.go
go run main.go >> output-go.txt &
PID=$!
sleep 30
kill $PID

cat output-go.txt | grep 'Successful connection!' -q

- name: Test Python Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd $EXAMPLES_DIR/python${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" main.py
pip install -r requirements.txt
python main.py >> output-python.txt &
PID=$!
sleep 30
kill $PID

cat output-python.txt | grep 'Successful connection!' -q

- name: Clean up
if: ${{ always() }}
run: |-
kubectl delete hazelcast my-hazelcast${{matrix.suffix}}
kubectl wait --for=delete pod/my-hazelcast${{matrix.suffix}}-0 --timeout=2m
kubectl get svc my-hazelcast${{matrix.suffix}} || exit 0
kubectl wait --for=delete svc/my-hazelcast${{matrix.suffix}} --timeout=5m

- name: Clean up Smart services
if: ${{ always() && matrix.type == 'smart' }}
run: |-
kubectl get svc my-hazelcast${{matrix.suffix}}-0 || exit 0
kubectl wait --for=delete svc/my-hazelcast${{matrix.suffix}}-0 --timeout=5m

clean-up:
name: Clean up GKE cluster
runs-on: ubuntu-latest
needs: [run-tests, create-gke-cluster]
if: ${{ always() }}
env:
CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
steps:
- name: Authenticate to GCP
uses: "google-github-actions/[email protected]"
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.GCP_PROJECT_ID }}

# Clean up
- name: Delete cluster
run: |-
gcloud container clusters delete "$CLUSTER_NAME" --zone="$GKE_ZONE" --quiet
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
target/
.idea/
.vscode/
.settings/
.classpath
.directory
.project
.surefire-*
.DS_Store
*.iml
*.ipr
*.iws
*node_modules/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See the link:https://docs.hazelcast.com/tutorials/hazelcast-platform-operator-expose-externally[tutorial].
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
asciidoctor -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc;
asciidoctor-pdf -D . -a allow-uri-read docs/modules/ROOT/pages/*.adoc;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Hazelcast;
using Microsoft.Extensions.Logging;


class CsharpExample
{
static async Task Main(string[] args)
{

var options = new HazelcastOptionsBuilder()
.With(args)
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.SmartRouting = false;
})
.Build();
var client = await HazelcastClientFactory.StartNewClientAsync(options);


Console.WriteLine("Successful connection!");
Console.WriteLine("Starting to fill the map with random entries.");

var map = await client.GetMapAsync<string, string>("map");
var random = new Random();
while (true)
{
var randomKey = random.Next(100_000);
await map.PutAsync("key-" + randomKey, "value-" + randomKey);
Console.WriteLine("Current map size: " + await map.GetSizeAsync());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>kuberentesOut</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hazelcast.Net" Version="5.5.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Hazelcast;
using Microsoft.Extensions.Logging;

class csharp_example
{
static async Task Main(string[] args)
{
var options = new HazelcastOptionsBuilder()
.With(args)
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.UsePublicAddresses = true;
})
.Build();
var client = await HazelcastClientFactory.StartNewClientAsync(options);


Console.WriteLine("Successful connection!");
Console.WriteLine("Starting to fill the map with random entries.");

var map = await client.GetMapAsync<string, string>("map");
var random = new Random();
while (true)
{
var randomKey = random.Next(100_000);
await map.PutAsync("key-" + randomKey, "value-" + randomKey);
Console.WriteLine("Current map size: " + await map.GetSizeAsync());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hazelcast.Net" Version="5.5.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
</ItemGroup>

</Project>
Loading
Loading