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

Remote Url wait time #1

Closed
rusucosmin opened this issue Mar 29, 2018 · 11 comments
Closed

Remote Url wait time #1

rusucosmin opened this issue Mar 29, 2018 · 11 comments

Comments

@rusucosmin
Copy link

How much time do we need to wait to get the remote URL?

I've been waiting for 15 mins and it seems like it's still null.

@rusucosmin
Copy link
Author

A couple of updates. I'm running k8s on GKE. I'm not sure how to set this docker secret:

  registry:
  url: "registry.io/user"
  credentials:
  # dockercfg secret
    secretKeyRef:
      name: regsecret
      key: .dockercfg

I believe the URL is "gcr.io", and we don't really need credentials since the registry is by default accesible from within the cluster?

@tirumaraiselvan
Copy link
Contributor

@rusucosmin It should be almost instantaneous. Can you paste the output of

$ kubectl get pods -n kube-system | grep gitkube

$ kubectl get svc -n kube-system gitkubed

and finally your remote

$ kubectl get remotes <remote-name> -o yaml

@rusucosmin
Copy link
Author

@tirumaraiselvan thanks for the quick response:

$ kubectl get pods -n kube-system | grep gitkube
gitkube-controller-79fcb89689-flpt2                          1/1       Running   0          1h
gitkubed-6ccb9b8c6c-gghp2                                    1/1       Running   0          15m
apiVersion: gitkube.sh/v1alpha1
kind: Remote
metadata:
  clusterName: ""
  creationTimestamp: 2018-03-29T18:43:52Z
  deletionGracePeriodSeconds: null
  deletionTimestamp: null
  initializers: null
  name: example
  namespace: default
  resourceVersion: "250597"
  selfLink: /apis/gitkube.sh/v1alpha1/namespaces/default/remotes/example
  uid: 209b5a19-3381-11e8-bc77-42010a84004c
spec:
  authorizedKeys:
  - ssh-rsa apiVersion: gitkube.sh/v1alpha1
kind: Remote
metadata:
  clusterName: ""
  creationTimestamp: 2018-03-29T18:43:52Z
  deletionGracePeriodSeconds: null
  deletionTimestamp: null
  initializers: null
  name: example
  namespace: default
  resourceVersion: "250597"
  selfLink: /apis/gitkube.sh/v1alpha1/namespaces/default/remotes/example
  uid: 209b5a19-3381-11e8-bc77-42010a84004c
spec:
  authorizedKeys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDdTIotLAand_so_on
    rusucosmin@rhino
  deployments:
  - containers:
    - dockerfile: Dockerfile
      name: nginx
      path: .
    name: nginx
  registry:
    url: gcr.io/dutylabs-adhoc    rusucosmin@rhino
  deployments:
  - containers:
    - dockerfile: Dockerfile
      name: nginx
      path: .
    name: nginx
  registry:
    url: gcr.io/dutylabs-adhoc

@tirumaraiselvan
Copy link
Contributor

tirumaraiselvan commented Mar 29, 2018

@rusucosmin I would also need

$ kubectl get svc -n kube-system gitkubed

and I think there is some error in copying the output of

$ kubectl get remotes <remote-name> -o yaml

For e.g. in this example, it should be

$ kubectl get remotes example -o yaml

Can you please check that again?

@rusucosmin
Copy link
Author

Yes, here it is:

$ kubectl get svc -n kube-system gitkubed

NAME       TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
gitkubed   LoadBalancer   10.51.248.38   35.195.243.80   22:32320/TCP   1h


$ kubectl get remotes example -o yaml

apiVersion: gitkube.sh/v1alpha1
kind: Remote
metadata:
  clusterName: ""
  creationTimestamp: 2018-03-29T18:43:52Z
  generation: 0
  initializers: null
  name: example
  namespace: default
  resourceVersion: "251571"
  selfLink: /apis/gitkube.sh/v1alpha1/namespaces/default/remotes/example
  uid: 209b5a19-3381-11e8-bc77-42010a84004c
spec:
  authorizedKeys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDdTIotLA9WQblahblahblah
    rusucosmin@rhino
  deployments:
  - containers:
    - dockerfile: Dockerfile
      name: nginx
      path: .
    name: nginx
  registry:
    credentials:
      secretKeyRef:
        key: ""
    url: gcr.io/dutylabs-adhoc
status:
  remoteUrl: ssh://default-example@35.195.243.80/~/git/default-example
  remoteUrlDesc: ""

@tirumaraiselvan
Copy link
Contributor

All looks good here. I can also see that a remoteUrl was generated ( see the status section). Did it just work now after a long time? Or are you still seeing some null output somewhere?

@rusucosmin
Copy link
Author

Oh yeah, just noticed it actually worked!

kubectl get remotes                                                                                            ✖ ✹ ✭
NAME      AGE
example   34m

I think I only had to specify:

registry:
  url: "gcr.io/project-name"

without the credentials.

Thanks a lot, I'll close this issue.

@tirumaraiselvan
Copy link
Contributor

No problem @rusucosmin . So I assume you are able to do a git push successfully?

@rusucosmin
Copy link
Author

@tirumaraiselvan

I'm having some issues right now with the git push example master command.

$ git push example master
Counting objects: 24, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (23/23), done.
Writing objects: 100% (24/24), 6.66 KiB | 2.22 MiB/s, done.
Total 24 (delta 8), reused 0 (delta 0)
remote: Gitkube build system : Thu Mar 29 19:35:36 UTC 2018: Initialising
remote:
remote: Creating the build directory
remote: Checking out 'master:e5db63feb6f7b36107c8803a2a4623d6880fcab5' to '/home/default-example/build/default-example'
remote:
remote: 1 deployment(s) found in this repo
remote: Trying to build them...
remote:
remote: Building Docker image for : nginx
remote:
remote: Building Docker image : gcr.io/dutylabs-adhoc/default-example-default.nginx-nginx:e5db63feb6f7b36107c8803a2a4623d6880fcab5
remote: WARNING: Error loading config file:/home/default-example/.dockercfg - Invalid Auth config file
remote: Sending build context to Docker daemon 12.29 kB
remote: Step 1/2 : FROM nginx:stable-alpine
remote:  ---> 24ed1c575f81
remote: Step 2/2 : COPY html/ /usr/share/nginx/html
remote:  ---> Using cache
remote:  ---> b548b307adc2
remote: Successfully built b548b307adc2
remote: pushing gcr.io/dutylabs-adhoc/default-example-default.nginx-nginx:e5db63feb6f7b36107c8803a2a4623d6880fcab5 to registry
remote: WARNING: Error loading config file:/home/default-example/.dockercfg - Invalid Auth config file
remote: The push refers to a repository [gcr.io/dutylabs-adhoc/default-example-default.nginx-nginx]
remote: e1309e052ca1: Preparing
remote: 68695a6cfd7d: Preparing
remote: c1dc81a64903: Preparing
remote: 8460a579ab63: Preparing
remote: d39d92664027: Preparing
remote: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
To ssh://35.195.243.80/~/git/default-example
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://default-example@35.195.243.80/~/git/default-example'

Here is the full output of the command.

@tirumaraiselvan
Copy link
Contributor

As the error suggests, it seems gitkube is not authorized to push to gcr. I haven't worked with gcr authentication yet. But I looked up the docs. It is a straightforward process to create the secret: https://cloud.google.com/container-registry/docs/advanced-authentication#using_a_json_key_file

  1. Download the JSON key for your Container Registry service account : https://support.google.com/cloud/answer/6158849#serviceaccounts (let's call it keyfile.json)

  2. Create a docker-registry secret with the following command:

Make sure your kubectl client version is 1.8 or prior. Latest client version 1.9 has a issue: hasura/gitkube#38 . If you have 1.9, just download 1.8 somewhere and execute it directly.

$ kubectl create secret docker-registry regsecret --docker-server=https://gcr.io --docker-username="_json_key" --docker-password="$(cat keyfile.json)" --docker-email=<your-email>
  1. Add credentials to your remote.yaml
registry:
  url: gcr.io/dutylabs-adhoc/
  credentials:
  # dockercfg secret
    secretKeyRef:
      name: regsecret
      key: .dockercfg
  1. Replace your remote with the new spec:
$ kubectl replace -f remote.yaml
  1. Push

@rusucosmin
Copy link
Author

Thanks, it worked now. I had locally version 1.9 but on the servers 1.8 so I connected from the google cloud console shell and run the secret from there.

This project is very useful, great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants