bank-of-anthos: Not able to start the application on Single node k8 cluster on a Laptop

Describe the bug

The application is looking for GCP credentials on local deployment

To Reproduce

  1. kubectl apply -f ./extras/jwt/jwt-secret.yaml
  2. Followed the steps for NON-GKE cluster https://github.com/GoogleCloudPlatform/bank-of-anthos/blob/main/docs/environments.md
  3. Turned off metrics/logs/traces export from a non-GKE cluster into Google Cloud Operations: set ENABLE_METRICS=false and ENABLE_TRACING=false
  4. kubectl apply -f ./kubernetes-manifests

Logs

kubectl get pods
NAME                                  READY   STATUS             RESTARTS        AGE
accounts-db-0                         1/1     Running            0               11m
balancereader-5b68d6759d-dx5b2        0/1     CrashLoopBackOff   6 (111s ago)    11m
contacts-79f7bdbd65-n5zzj             1/1     Running            0               11m
frontend-586f7c65b6-c9f9l             1/1     Running            0               11m
ledger-db-0                           1/1     Running            0               11m
ledgerwriter-6cb4c54c8b-rdqcz         0/1     CrashLoopBackOff   6 (2m19s ago)   11m
loadgenerator-7d76b79db9-j5jnx        1/1     Running            0               11m
transactionhistory-5975dfb8b6-ktfc6   0/1     CrashLoopBackOff   6 (2m24s ago)   11m
userservice-654b49d949-vwkkm          1/1     Running            0               11m
kubectl logs -f balancereader-5b68d6759d-dfm62

org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) ~[spring-boot-3.1.5.jar:3.1.5]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) ~[spring-boot-3.1.5.jar:3.1.5]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-3.1.5.jar:3.1.5]
	... 8 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stackdriverSender' defined in class path resource [com/google/cloud/spring/autoconfigure/trace/StackdriverTraceAutoConfiguration.class]: Failed to instantiate [zipkin2.reporter.Sender]: Factory method 'stackdriverSender' threw exception with message: Your default credentials were not found. To set up Application Default Credentials for your environment, see https://cloud.google.com/docs/authentication/external/set-up-adc.
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:654) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:642) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) ~[spring-beans-6.0.13.jar:6.0.13]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:910) ~[spring-beans-6.0.13.jar:6.0.13]

Screenshots

Environment

  • OS: Apple M1 Max || v14.2.1]
  • Kubernetes distribution V1.28.2 via Docker Desktop v4.26.1
  • Docker Engine : 24.0.7

Additional context

Trying to setup the demo app on an isolated K8 single node k8 cluster.

Exposure

It’s persistent on the environment.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

v0.6.4 (just released today) should have that fix built-in now! https://github.com/GoogleCloudPlatform/bank-of-anthos/releases/tag/v0.6.4

Can you try applying this balance-reader.yaml to see if it fixes the problem:

# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: balancereader-application-properties
data:
  application.properties: |-
    server.port = ${PORT}
    handlers = java.util.logging.ConsoleHandler
    spring.main.banner-mode=off
    # tracing on/off toggle
    spring.sleuth.enabled = ${ENABLE_TRACING}
    spring.cloud.gcp.trace.enabled=${ENABLE_TRACING}
    # if tracing enabled, configuration options:
    spring.sleuth.sampler.probability=1.0
    spring.sleuth.web.skipPattern=(^cleanup.*|.+favicon.*)
    spring.sleuth.log.slf4j.enabled=false
    #enables all tomcat metrics to be recorded
    server.tomcat.mbeanregistry.enabled=true
    #enables jpa metrics to be recorded
    spring.jpa.properties.hibernate.generate_statistics=true
    #set the jpa database platform
    spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
---
apiVersion: v1
kind: Service
metadata:
  labels:
    application: bank-of-anthos
    environment: development
    team: ledger
    tier: backend
  name: balancereader
spec:
  ports:
    - name: http
      port: 8080
      targetPort: 8080
  selector:
    app: balancereader
    application: bank-of-anthos
    environment: development
    team: ledger
    tier: backend
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    application: bank-of-anthos
    environment: development
    team: ledger
    tier: backend
  name: balancereader
spec:
  selector:
    matchLabels:
      app: balancereader
      application: bank-of-anthos
      environment: development
      team: ledger
      tier: backend
  template:
    metadata:
      annotations:
        proxy.istio.io/config: '{ "holdApplicationUntilProxyStarts": true }'
      labels:
        app: balancereader
        application: bank-of-anthos
        environment: development
        team: ledger
        tier: backend
    spec:
      containers:
        - env:
            - name: VERSION
              value: v0.6.3
            - name: PORT
              value: "8080"
            - name: ENABLE_TRACING
              value: "false"
            - name: ENABLE_METRICS
              value: "false"
            - name: POLL_MS
              value: "100"
            - name: CACHE_SIZE
              value: "1000000"
            - name: JVM_OPTS
              value: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Xms256m -Xmx512m
            - name: LOG_LEVEL
              value: info
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          envFrom:
            - configMapRef:
                name: environment-config
            - configMapRef:
                name: ledger-db-config
          image: us-central1-docker.pkg.dev/bank-of-anthos-ci/bank-of-anthos/balancereader:v0.6.3@sha256:77ffd99c87d800e842f19fb76c82f043b237d0569651e376dcb1d3ff2c14e140
          livenessProbe:
            httpGet:
              path: /healthy
              port: 8080
            initialDelaySeconds: 120
            periodSeconds: 5
            timeoutSeconds: 10
          name: balancereader
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            initialDelaySeconds: 60
            periodSeconds: 5
            timeoutSeconds: 10
          resources:
            limits:
              cpu: 500m
              ephemeral-storage: 0.5Gi
              memory: 512Mi
            requests:
              cpu: 100m
              ephemeral-storage: 0.5Gi
              memory: 256Mi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - all
            privileged: false
            readOnlyRootFilesystem: true
          startupProbe:
            failureThreshold: 30
            httpGet:
              path: /healthy
              port: 8080
            periodSeconds: 10
          volumeMounts:
            - mountPath: /tmp
              name: tmp
            - mountPath: /tmp/.ssh
              name: publickey
              readOnly: true
            - mountPath: "/app/resources/"
              name: application-properties
              readOnly: true
      securityContext:
        fsGroup: 1000
        runAsGroup: 1000
        runAsNonRoot: true
        runAsUser: 1000
      serviceAccountName: bank-of-anthos
      terminationGracePeriodSeconds: 5
      volumes:
        - emptyDir: {}
          name: tmp
        - name: publickey
          secret:
            items:
              - key: jwtRS256.key.pub
                path: publickey
            secretName: jwt-key
        - name: application-properties
          configMap:
            name: balancereader-application-properties