Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Only 1 service is generated #28

Open
bobbydeveaux opened this issue Jan 9, 2024 · 2 comments
Open

[bug] Only 1 service is generated #28

bobbydeveaux opened this issue Jan 9, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@bobbydeveaux
Copy link

Describe the bug
When running score-helm run -f score.yaml -o manifest.yaml, it generates a file that is used by the 'score-helm-charts/workload' helm chart. However, despite my score.yaml file containing 2 services, the helm-chart creates a service in k8s as 1 service with 2 pods.

To Reproduce

apiVersion: score.dev/v1b1

metadata:
  name: both

containers:
  backend:
    image: be:1.0.0

  frontend:
    image: fe:1.0.0

service:
  ports:
    frontend:
      port: 8080
      targetPort: 8080
    backend:
      port: 8000
      targetPort: 8000

resources:
  env:
    type: environment

  my-be-dns:
    type: dns

  my-fe-dns:
    type: dns

  bobby-bucket:
    type: s3

  backend-route:
    type: route
    params:
      path: /api
      port: 8000
      host: ${resources.my-be-dns.host}

  frontend-route:
    type: route
    params:
      path: /
      port: 8080
      host: ${resources.my-fe-dns.host}

score-helm run -f score.yaml -o manifest.yaml

helm install test-app score-helm-charts/workload --values ./manifest.yaml

Expected behavior
Would expect an 2 deployments within k8s - and 2 services running.

@bobbydeveaux bobbydeveaux added the bug Something isn't working label Jan 9, 2024
@astromechza
Copy link
Member

Just looking at the output quickly I can see the manifest looks like

$ go run github.com/score-spec/score-helm/cmd/score-helm@latest run score.yaml
go: downloading github.com/score-spec/score-helm v0.0.0-20240105083034-d29b2dfdefe6
go: downloading github.com/score-spec/score-go v0.0.0-20230905115428-131acdd2f5cf
containers:
  backend:
    image:
      name: be:1.0.0
  frontend:
    image:
      name: fe:1.0.0
service:
  ports:
    - name: backend
      port: 8000
      targetPort: 8000
    - name: frontend
      port: 8080
      targetPort: 8080
  type: ClusterIP

And the helm output looks like

$ helm template demo score-helm-charts/workload --values manifest.yaml
---
# Source: workload/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: demo
  labels:
    helm.sh/chart: workload-0.4.0
    app.kubernetes.io/name: demo
    app.kubernetes.io/instance: demo
    app.kubernetes.io/version: "0.4.0"
    app.kubernetes.io/managed-by: Helm
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: demo
    app.kubernetes.io/instance: demo
  ports:
    - name: backend
      port: 8000
      targetPort: 8000
    - name: frontend
      port: 8080
      targetPort: 8080
---
# Source: workload/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo
  labels:
    helm.sh/chart: workload-0.4.0
    app.kubernetes.io/name: demo
    app.kubernetes.io/instance: demo
    app.kubernetes.io/version: "0.4.0"
    app.kubernetes.io/managed-by: Helm
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: demo
      app.kubernetes.io/instance: demo
  template:
    metadata:
      labels:
        app.kubernetes.io/name: demo
        app.kubernetes.io/instance: demo
    spec:
      containers:
        - name: backend
          image: "be:1.0.0"
        - name: frontend
          image: "fe:1.0.0"

So the service has both ports on it.

@astromechza
Copy link
Member

Unfortunately @bobbydeveaux this is expected behavior, Score is a workload spec and generates 2 containers in the same pod (the same workload).

If you're looking for 2 services (backed by different deployments) you should be looking at 2 separate Score files.

@astromechza astromechza self-assigned this Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants