Skip to content

Conversation

@EmersonDove
Copy link
Contributor

@EmersonDove EmersonDove commented Jul 20, 2022

This PR adds full support for GCP and Kubernetes.

GCP Usage:

machine1 = fogros2.GCPCloudInstance(
        project_id='gcp-project'
    )

Kubernetes Usage

machine1 = fogros2.GCPKubeInstance()

Requires gcloud CLI and/or kubectl on local host

Changes to review:

  • The cloud instance exposes an ip property and now a vpn_ip property. Kubernetes has separate addresses for the two services so a modification was also made to the VPN class
  • Enforced the ubuntu username in ClouldInstance

Known Issues:

  • boto3 (any python dependencies) is not recognized on remote launch for both kube and GCP
  • Depending on kubectl gcloud configuration a warning can disrupt the parsing done for kubernetes responses

user = subprocess.check_output('whoami', shell=True).decode().strip()

# Username
self._username = (open(f'/home/{user}/.ssh/google_compute_engine.pub').
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to break this up into more separate steps, as it is tough to parse what is going on currently.

pod_config: dict = json.loads(open(f'{kube_wd}/pod.json').read())

# Configure the pod
pod_config['spec']['containers'][0]["image"] = self.container_image
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps change the quotations around "image" to be ' to match the rest of the strings.


# Configure the pod
pod_config['spec']['containers'][0]["image"] = self.container_image
pod_config['spec']['containers'][0]["name"] = self._name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps change the quotations around "name" to be ' to match the rest of the strings.

pod_config['spec']['containers'][0]["image"] = self.container_image
pod_config['spec']['containers'][0]["name"] = self._name
pod_config['spec']['containers'][0]['resources']['requests']['memory'] = str(self._mmb) + 'Mi'
pod_config['spec']['containers'][0]['resources']['requests']['cpu'] = str(self._mcpu) + "m"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose for some of these, the string quotations aren't consistent across the board, and it would be great if they could be unified.

Copy link
Collaborator

@KDharmarajanDev KDharmarajanDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think it looks good! One question I have is if there are requirements (gcloud?) you could add to the requirements.txt or package.xml.

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

Successfully merging this pull request may close these issues.

2 participants