GoogleCloudPlatform / cloud-code-vscode

Cloud Code for Visual Studio Code: Issues, Documentation and more
Other
420 stars 112 forks source link

The connection to the server localhost:8080 was refused - did you specify the right host or port? #819

Closed 123Blessed closed 1 year ago

123Blessed commented 1 year ago

Environment: dev (Hint: "Report Extension Issue on Github" command will fill these out for you.) Managed Dependencies: ON

Version information

Cloud Code Extension version:

VSCode version:

OS: UBUNTU

Cloud SDK: 437.0.1

Skaffold: v2.5.0

Description: I created a workflow on github action that has 2 job. The first build the image and the second deploy to GKE. for some reason the second job is not able to dfeploy to GKE becasue 'The connection to the server localhost:8080 was refused - did you specify the right host or port?'. However, when it was only one job that build and deploy to GKE, it was working fine. Any idea on how to remove this impediment?

Repro step: bellow is my workflow:

name: Low Environment Build and Deploy to GKE

on:

push:

#branches:
  #- feature/DEVOPS-359

workflow_dispatch: inputs: tags1: description: 'Scenario tags1 after deploying on command' required: false type: choice options:

env: PROJECT_ID: ${{ secrets.GKE_PROJECT }} GKE_CLUSTER: ${{vars.GKE_CLUSTER}} # Add your cluster name here. GKE_ZONE: ${{vars.GKE_ZONE}} # Add your cluster zone here. DEPLOYMENT_NAME: medsitter-command # Add your deployment name here. IMAGE: ${{vars.GKE_IMAGE}} NAMESPACE: ${{vars.GKE_NAMESPACE}} DIRECTORY: ${{vars.GKE_DIRECTORY}} APP_KEY: ${{ secrets.APP_KEY }} GITHUB_KEY: ${{ secrets.COMPOSER_GITHUB_KEY }} MIX_PUSHER_APP_KEY: ${{ secrets.MIX_PUSHER_APP_KEY}} MIX_ELIVIO_ACCOUNT_ID: ${{ secrets.MIX_ELIVIO_ACCOUNT_ID}} ACTIONS_STEP_DEBUG: true

jobs: setup-build-publish-deploy: name: Setup, Build, and Publish runs-on: ubuntu-latest environment: ${{inputs.GKE_environment}} permissions: contents: 'read' id-token: 'write'

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

# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0.5.1

  with:
    service_account_key: ${{ secrets.GKE_SA_KEY }}

    project_id: ${{ secrets.GKE_PROJECT }}
    export_default_credentials: true

# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
    gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@v1.0.2

  with:
    project_id: ${{ secrets.GKE_PROJECT }}
    cluster_name: ${{ env.GKE_CLUSTER }}
    location: ${{ env.GKE_ZONE }}
    #service_account_key: {{ secrets.GKE_SA_KEY }}

- name: Build latest
  run: |-
    docker build \
      --tag "us.gcr.io/$PROJECT_ID/$IMAGE/github.com/repo/container:latest" --tag "us.gcr.io/$PROJECT_ID/$IMAGE/github.com/repo/container:$GITHUB_SHA" -f Dockerfile \
      --build-arg GITHUB_SHA="$GITHUB_SHA" \
      --build-arg GITHUB_REF="$GITHUB_REF" \
      . 
# Push the Docker image to Google Container Registry
- name: Publish latest
  run: |-
    docker push  --all-tags us.gcr.io/$PROJECT_ID/$IMAGE/github.com/repo/container
- name: Set up Kustomize
  working-directory: ./Kubernetes/${{vars.GKE_DIRECTORY}}
  run: |-
    curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
    chmod u+x ./kustomize

Deployment_job: name: Deploy runs-on: ubuntu-latest environment: ${{inputs.GKE_environment}} permissions: contents: 'read' id-token: 'write' needs: setup-build-publish-deploy

if#: needs.setup-build-publish-deploy.result == 'success'

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

- name: Set up Kustomize
  working-directory: ./Kubernetes/${{vars.GKE_DIRECTORY}}
  run: |-
    curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
    chmod u+x ./kustomize  
# Deploy the Docker image to the GKE cluster
- name: Deploy

  working-directory: ./Kubernetes/${{vars.GKE_DIRECTORY}}

  run: |-        
    ./kustomize edit set image us.gcr.io/$PROJECT_ID/$IMAGE/github.com/repo/container:TAG=us.gcr.io/$PROJECT_ID/$IMAGE/github.com/repo/container:$GITHUB_SHA
    ./kustomize build . | kubectl apply -f -
    kubectl config set-context --current --namespace=$NAMESPACE
    kubectl set image deployment/command container=us.gcr.io/$PROJECT_ID/$IMAGE/github.com/repo/container:$GITHUB_SHA --namespace=$NAMESPACE
    kubectl rollout status deployment/command
    kubectl exec deploy/command -c container -- ${{ inputs.tags1 }}
    kubectl exec deploy/command -c container -- ${{ inputs.tags2 }}
    kubectl set image deployment/medsitter-kube container=us.gcr.io/$PROJECT_ID/$IMAGE/github.com/idsolutions/medsitter-web-edition:$GITHUB_SHA --namespace=$NAMESPACE
    kubectl rollout status deployment/kube
    kubectl get services -o wide
SKrupa commented 1 year ago

Hi, is this an issue when using Google Cloud Code for VSCode extension? Or is this coming from Google Cloud Build? If its the latter, could you report this bug via the Send Feedback button within the Cloud Build page in Cloud Console?

123Blessed commented 1 year ago

The issue is happening on github action. This is issue is not completed, it shouldn't be closed