hasura / gitkube

Build and deploy docker images to Kubernetes using git push
Apache License 2.0
3.81k stars 208 forks source link

Expose gitkube as NodePort type #36

Closed sdileep closed 6 years ago

sdileep commented 6 years ago

I'm trying to experiment with gitkube on a local cluster(not minikube) and hence exposed it as NodePort type service. After creating a remote as per example, I am not able to retrieve the remote URL using $ kubectl get remote example -o json | jq -r '.status.remoteUrl. Am I missing something?

ps: the example worked on GCE without any issues.

shahidhk commented 6 years ago

@sdileep Can you paste the kubectl command you used to expose gitkube and the the output of kubectl get remote example -o yaml here?

coco98 commented 6 years ago

@shahidhk Once we help @sdileep out, let's add instructions for minikube to our docs too!

sdileep commented 6 years ago

@coco98 This is not a minikube environment(mentioned it above). I'm running a couple VMs using VirtualBox and Vagrant. The VMs are on a private network with static IP addresses assigned to them. The cluster was created with kubeadm and kube-dashboard & a sample service for nginx are up and running fine on the cluster

@shahidhk The command that I used was kubectl --kubeconfig <path_to_conf> --namespace kube-system expose deployment gitkubed --type=NodePort --name=gitkubed. The output for the commandkubectl get remote example -o yaml` is

apiVersion: gitkube.sh/v1alpha1
kind: Remote
metadata:
  clusterName: ""
  creationTimestamp: 2018-03-24T12:12:02Z
  name: example
  namespace: default
  resourceVersion: "25276"
  selfLink: /apis/gitkube.sh/v1alpha1/namespaces/default/remotes/example
  uid: 8f664f88-2f5c-11e8-8cb2-525400daa710
spec:
  authorizedKeys:
  - ssh-rsa <key>
  - ssh-rsa <AAAAB3NzaC1yc2...  ...zqCcCZT>
    <user@Machine>
  deployments:
  - containers:
    - dockerfile: Dockerfile
      name: nginx
      path: .
    name: nginx

Since I don't have a load balancer, the remote url isn't generated I reckon.

shahidhk commented 6 years ago

@sdileep Can you try setting this remote manually?

$ git remote add example ssh://default-example@<any-node-id>:<node-port>/~/git/default-example

Also, it'll be helpful if you can paste relevant log lines from gitkube-controller so that we could figure out a fix?

NodePort service objects does not have an external ip field in the spec. Hence gitkube might not be able to figure out the IP. But, this should have been reported as a message in the remote object status.

tirumaraiselvan commented 6 years ago

kubectl get remote example -o yaml should have had status section. The status will have a remoteUrlDesc which would tell you to add remote manually since it is of type NodePort. This should be fixed by https://github.com/hasura/gitkube/pull/37

Apart from this, as @shahidhk mentioned, we do not have the external ip for nodeport service in the service object. We can work around this by going through all the nodes and getting the ip of one of the nodes and filling it in the remote. PRs welcome for this.

sdileep commented 6 years ago

@shahidhk The logs from the controller are as follows:

time="2018-03-24T14:31:18Z" level=info msg="Setting up event handlers"
time="2018-03-24T14:31:18Z" level=info msg="Initialising gitkube"
time="2018-03-24T14:31:18Z" level=info msg="Waiting for cache sync"
time="2018-03-24T14:31:18Z" level=info msg="Caches are synced"
time="2018-03-24T14:31:18Z" level=info msg="Starting remote worker"
time="2018-03-24T14:31:18Z" level=info msg="Starting configmap worker"
time="2018-03-24T14:31:18Z" level=info msg="Waiting for stop signal"
time="2018-03-24T14:31:18Z" level=info msg="syncing configmap: kube-system.gitkube-ci-conf"
time="2018-03-24T14:31:18Z" level=info msg="syncing configmap: kube-system.gitkube-ci-conf"
time="2018-03-24T17:44:35Z" level=info msg="syncing remote: default.example"

Logs from gitkubed are as follows:

...
Could not load host key: /etc/ssh/ssh_host_dsa_key
Did not receive identification string from 10.1.1.1 port 37504
rexec line 19: Deprecated option KeyRegenerationInterval
rexec line 20: Deprecated option ServerKeyBits
rexec line 31: Deprecated option RSAAuthentication
rexec line 38: Deprecated option RhostsRSAAuthentication
Could not load host key: /etc/ssh/ssh_host_dsa_key
Did not receive identification string from 10.1.1.1 port 37508
rexec line 19: Deprecated option KeyRegenerationInterval
rexec line 20: Deprecated option ServerKeyBits
rexec line 31: Deprecated option RSAAuthentication
rexec line 38: Deprecated option RhostsRSAAuthentication
Could not load host key: /etc/ssh/ssh_host_dsa_key
Did not receive identification string from 10.1.1.1 port 37512
rexec line 19: Deprecated option KeyRegenerationInterval
rexec line 20: Deprecated option ServerKeyBits
rexec line 31: Deprecated option RSAAuthentication
rexec line 38: Deprecated option RhostsRSAAuthentication
Could not load host key: /etc/ssh/ssh_host_dsa_key
Did not receive identification string from 10.1.1.1 port 37516
rexec line 19: Deprecated option KeyRegenerationInterval
rexec line 20: Deprecated option ServerKeyBits
rexec line 31: Deprecated option RSAAuthentication
rexec line 38: Deprecated option RhostsRSAAuthentication
...

^^ those logs seems to keep repeating for every 4th port

@shahidhk thanks for the git remote url, the one from the example doc is not correct. This solves the issue for me.