Giter VIP home page Giter VIP logo

Comments (11)

rusucosmin avatar rusucosmin commented on May 18, 2024

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?

from gitkube-example.

tirumaraiselvan avatar tirumaraiselvan commented on May 18, 2024

@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

from gitkube-example.

rusucosmin avatar rusucosmin commented on May 18, 2024

@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

from gitkube-example.

tirumaraiselvan avatar tirumaraiselvan commented on May 18, 2024

@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?

from gitkube-example.

rusucosmin avatar rusucosmin commented on May 18, 2024

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://[email protected]/~/git/default-example
  remoteUrlDesc: ""

from gitkube-example.

tirumaraiselvan avatar tirumaraiselvan commented on May 18, 2024

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?

from gitkube-example.

rusucosmin avatar rusucosmin commented on May 18, 2024

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.

from gitkube-example.

tirumaraiselvan avatar tirumaraiselvan commented on May 18, 2024

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

from gitkube-example.

rusucosmin avatar rusucosmin commented on May 18, 2024

@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://[email protected]/~/git/default-example'

Here is the full output of the command.

from gitkube-example.

tirumaraiselvan avatar tirumaraiselvan commented on May 18, 2024

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

from gitkube-example.

rusucosmin avatar rusucosmin commented on May 18, 2024

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!

from gitkube-example.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.