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

Service deployment to AKS failure on verification step due to Redis targetPort tag being assigned as string. #2270

Closed
1 task done
julioalex-rezende opened this issue May 19, 2023 · 0 comments · Fixed by #2274
Assignees
Labels
aks Azure Kubernetes Service core customer-reported identify a customer issue question

Comments

@julioalex-rezende
Copy link

Output from azd version

 azd version 0.9.0-beta.2 (commit afa7ac6e839be8304b86b3df6b8525a97e48a532)

Describe the bug

When deploying Redis on an AKS cluster and redeploying services through azd cli on the same namespace, the step that verifies if the deployment was made correctly fails, causing the command to interrupt.

# Deploy services again (either through *azd up* or *azd deploy*)
azd deploy [--debug]
...
...
  (x) Failed: Deploying service public-api-service

ERROR: failed deploying service 'public-api-service': failing invoking action 'deploy', failed retrieving service endpoints, failed waiting for resource, failed waiting for resource, failed unmarshalling resources JSON, json: cannot unmarshal string into Go struct field Port.items.spec.ports.targetPort of type int

After investigation, it seems that azd expects the json output from the AKS services to have targetPorts assigned to integer values only, whereas through redis deployment, this value is a literal string called redis and the ports are sorted at pod level

To Reproduce
A reproducible setup was created in this repository. Instructions are included in the README file.

Expected behavior
There shouldn't be any error on deployment. Especially because the deployment itself was successful, and the failure is on the verification step.

Environment
Information on your environment:
* Language name and version
* IDE and version: Visual Studio Code 1.78.2

Additional context

Things to notice:

  • deployment of services works correctly and fails only on the validation step
  • command fails during JSON parsing when verifying deployment (kubectl -get svc -n <environment_name> -json)
  • this interrupts the command, thus following services are not deployed
  • if we get the Redis manifest, make changes to targetPorts, and then deploy with kubectl apply, deployment with azd does not complain anymore.
  • this issue was found with Redis deployment, but any deployment that does the same with the targetPorts will probably result in the same issue

It's possible to check the JSON file with the following command:

kubectl get service --namespace <namespace> -o json

For all Redis-related services (redis-headless, redis-master, redis-replicas) the value for ports.TargetPort is a literal string. That's the cause of conflict with azd

"spec": {
    ...
    "ports": [
        {
            "name": "tcp-redis",
            "port": 6379,
            "protocol": "TCP",
            "targetPort": "redis"
        }
    ],
    ...
}

Looking at azd source code, targetPort field is specified as integer:

type Port struct {
	Port       int    `json:"port"`
	TargetPort int    `json:"targetPort"`
	Protocol   string `json:"protocol"`
}
@ghost ghost added needs-triage For new issues customer-reported identify a customer issue question labels May 19, 2023
@rajeshkamal5050 rajeshkamal5050 added the aks Azure Kubernetes Service label May 19, 2023
@ghost ghost removed the needs-triage For new issues label May 19, 2023
@ghost ghost removed the needs-triage For new issues label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aks Azure Kubernetes Service core customer-reported identify a customer issue question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants