quarkus-operator-sdk 備忘録

https://developers.redhat.com/articles/2023/08/16/how-implement-kubernetes-operators-java-operator-sdk

-> https://github.com/tkobayas/operator-examples/tree/main/echo-operator

minikube start

mvn clean compile
mvn quarkus:dev

kubectl apply -f src/test/resources/cr-test-echo-resource.yaml

kubectl get crd
kubectl describe crd echoresources.example.example.com
kubectl get echoresources

Github Action 備忘録

Windows でエラー

jobs:
  drools-build:
    ...
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
      ...
    steps:
      ...
      - name: Backward Compatibility Test
        run: |
          CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
          echo "Current version: $CURRENT_VERSION"

Windows だけエラー

The term 'CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)' is not recognized
as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.

shell: bash をつければよい。(Windows のデフォルトは PowerShell)

Java Performance tips

  • Use benchmark!

  • String.replace("A", "B") -> String.replace('A', 'B') : char is faster

  • String.format("%s.%s", strA, strB) -> StringBuilder.append(strA).append(".").append(strB) : format is better for maintenance, but StringBuilder would be faster for critical path
  • Avoid sort O(n log(n)) as possible
  • Be careful about Regex
  • Avoid long method
  • logger.debug("value = " + value) -> logger("value = {}", value)

Kafka on Openshift 備忘録

oc exec -it my-cluster-kafka-0 -- bash
bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic my-topic
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic my-topic --from-beginning