Git Product home page Git Product logo

gscloud's People

Contributors

ajfriesen avatar bkircher avatar cyberpanda avatar egypcio avatar fkr avatar ghostwheel42 avatar itakouna avatar janlukasgithub avatar marcharriss avatar miha-m avatar nvthongswansea avatar sharkwouter avatar twiebe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gscloud's Issues

Make sure json output is not too nested

Right now:

$ gscloud server ls --json | jq | head -n3
[
  [
    {

That's surprising and a bit too verbose. One list of objects is totally enough. Also check the other commands.

Creating a server without password fails

Creating a server with: gscloud server create --name test-1 --cores=1 --mem=1 --with-template="CentOS 8 (x86_64)" --hostname test-1

fails with
Server created: 1020a40a-f1d5-42da-8d65-877e9c159e94
Failed generating password: number of digits and symbols must be less than total length

according to @bkircher this is because if you leave the --password flag, a password is automatically generated - and the generated password doesn't pass the API requirements.

we expect to return the password, and the storage UUID

gscloud path lookup might fail when executed from search path

When gscloud is located in $PATH and executed in credential plugin mode with neither absolute nor relative path, but rather through search path lookup, path to gscloud is not correctly determined and stored in kubeconfig.

F.e. with gscloud located in /home/user/bin, /home/user/bin being in $PATH of user user and gscloud being executed with $ gscloud kubernetes cluster ... in current working dir /home/user, the resulting command inside kubeconfig will be /home/user/gscloud instead of /home/user/bin/gscloud

Add --include-related to gscloud-server-rm

Add a flag --include-related or something that removes attached storages and IPv{4,6} objects.

Example:

$ gscloud server rm --include-related 71385c7f-0cfc-4159-9611-0cc87fba0b34

Maybe with a security yes|no question.

Use kubeconfig expire timestamp in credentials

Current:
gscloud uses a fixed expiration time (e.g., 1 hour). https://github.com/gridscale/gscloud/blob/develop/cmd/kubernetes.go#L195

Expected:
gscloud uses the expiration time returned by API and stored in the credentials.

The expiration time is already in the kubeconfig returned from the PaaS service, e.g.,

{
  "paas_services": {
    "1612364a-6c2a-4806-a0b2-50542dd23d6d": {
      "service_template_uuid": "e32b413a-de8d-4380-a826-f2b493480103",
      "resource_limits": [],
      "security_zone_uuid": "da39a112-c195-4178-9875-0843b0bcb708",
      "object_uuid": "1612364a-6c2a-4806-a3b2-50542dd23d6d",
      "name": "gsk-internal-test4",
      "credentials": [
        {
          "type": "kubeconfig",
          "kubeconfig": "apiVersion: v1\nclusters:\n- cluster:\n    certificate-authority-data: .....", 
          "expiration_time": "2020-07-17T07:24:01Z"
        }
      ],
      ....
}

Docs: remove references to UUID, call it ID

Minor thing here.

Suggestion: we should call fields, columns, references to a resource identifier "ID" rather than "UUID". I believe that this field is internally a UUID4 is actually an implementation detail and we should start referring to it as ID.

Objections? Okay for me to create a PR?

Enable network creation

gscloud network --help

List, create, or remove networks.

Usage:
  gscloud network [command]

Available Commands:
  ls          List networks
  rm          Remove network

Global Flags:
      --account string   Specify the account used (default "default")
      --config string    Specify a configuration file (default "/Users/mharriss/Library/Application Support/gscloud/config.yaml")
  -h, --help             Print usage
  -j, --json             Print JSON to stdout instead of a table
      --noheading        Do not print column headings
  -q, --quiet            Print only IDs of objects

Use "gscloud network [command] --help" for more information about a command.

but it doens't seem that the "create" command has been implemented yet

so this task is to implement + add documentation

Add a --noheading flag

Add a --noheading -- Do not print column headings flag. It should turn off printing column header so that users can use grep and awk to extract data from the output more easily.

Implement iso-image subcommand

Missing:

gscloud iso-image create \
 --url=https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso \
 --name "Debian 10.7"

gscloud iso-image ls

gscloud iso-image rm <ID>

Avoid leaving unclean state when using gscloud-server-create

When server create fails somewhere in the middle of the whole thing it leaves objects behind that have already been created. This is unlike the panel which always cleans up nicely.

Panel uses POST /batch with

{
    "sub_calls": {
        "sub_calls": [
            {
                "call_type": "servers_post",
                "name": "ser1",
                "payload": {
                    "auto_recovery": true,
                    "availability_zone": null,
                    "cores": 1,
                    "hardware_profile": "q35",
                    "location_uuid": "8328a5bc-e66e-4edc-8aae-2e2bf07fdb28",
                    "memory": 1,
                    "name": "test-1"
                }
            },
            {
                "call_type": "storages_post",
                "name": "sto1",
                "payload": {
                    "capacity": 10,
                    "location_uuid": "8328a5bc-e66e-4edc-8aae-2e2bf07fdb28",
                    "name": "test-1",
                    "storage_type": "storage",
                    "template": {
                        "hostname": "test-1",
                        "password": "mysecret",
                        "password_type": "plain",
                        "template_uuid": "8d1bb5dc-7c37-4c90-8529-d2aaac75d812"
                    }
                }
            },
            {
                "call_type": "servers_storages_post",
                "name": "sto_x_ser",
                "payload": {
                    "bootdevice": true,
                    "server_uuid": "${SER1:SERVER_UUID}",
                    "storage_uuid": "${STO1:STORAGE_UUID}"
                }
            }
        ]
    }
}

to create a server. Not in API docs. You can observe this kind of behavior when user forgets to set --password in gscloud-server-create: new server object will be left while storage creation fails.

Ideas?

Add availability-zone string flag to gscloud-server-create

By placing servers in different availability zones, you can control the server's physical distance.

Add --availability-zone flag with 4 possible values:

  • the empty string (default), do not consider availability when placing this server object
  • a
  • b
  • c

Support --quiet flag

Add a --quiet flag to server, network, and other resources sub-commands. If given it should only print the UUID of the resource. For example:

$ gscloud server ls --quiet
8bbc3917-a0c0-42c5-b3b7-2087cc33cb82
1eebb354-7cc7-4b4b-8e7a-65ffeccc7359

It only prints the UUID to stdout followed by a newline. No table header is printed.

This would enable us to write things like

$ gscloud server ls --quiet | while read s; do
    gscloud server off -f $s
done

Make a better README

Work on a better README, esp. the first third needs some love. Make some simple examples that show how to work with this.

Wrong HW profile when creating servers

gscloud server create --name foo --cores=1 --mem=1 --with-template="CentOS 8 (x86_64)" --password=secret --hostname=foo

Creates a server with pc-i440fx-2.4 machine type (and no public net interface). It is tagged as "Standard" hardware profile in the panel. But actually haven't seen that before.

I would expect the default to be 'pc-q35-2.10' machine type which is tagged as "Q35 Chipset" hardware profile in the panel.

Not sure where this comes from, need to check gsclient-go and gridscale API docs.

gscloud path gets hard-coded into kubectl config

After setting up kubectl using gscloud kubectl now complains that it cannot find gscloud in /home/dennis/Downloads for some reason (I copied gscloud to /usr/local/bin):

$ kubectl get nodes
Unable to connect to the server: getting credentials: exec: fork/exec /home/dennis/Downloads/gscloud: no such file or directory

The problem seems to be that the path is hard-coded into the kubernetes config file as command: /home/dennis/Dowloads/gscloud. When I replace this with command: gscloud then kubectl finds the copy in /usr/local/bin and no longer throws an error.

Allow power cycle through command line

Something like

$ gscloud server on --name <name>
$ gscloud server on <id>

and

$ gscloud server off --name <name>
$ gscloud server off <id>

which would be ACPI and

$ gscloud server off --force <id>

would be hard power plug or something.

Add gscloud-paas

Implement gslcoud-paas along with all its sub-commands like list, create, rm.

Credential plugin cache directory is created in cwd

We're creating the gscloud cache directory in the current working dir at the moment:

$ pwd
/Users/thomas/tmp/gscloud
$ ls -la
total 0
drwxr-xr-x   2 thomas  staff    64B Jan 13 11:57 .
drwxr-xr-x  72 thomas  staff   2.3K Jan 13 11:57 ..
$ kubectl get nodes
NAME           STATUS   ROLES    AGE     VERSION
node-pool0-0   Ready    <none>   4d20h   v1.16.4
node-pool0-1   Ready    <none>   4d14h   v1.16.4
$ ls -la
total 0
drwxr-xr-x   3 thomas  staff    96B Jan 13 11:57 .
drwxr-xr-x  72 thomas  staff   2.3K Jan 13 11:57 ..
drwx------   3 thomas  staff    96B Jan 13 11:57 cache
$ find cache -ls
45820327        0 drwx------    3 thomas           staff                  96 Jan 13 11:57 cache
45820328        0 drwx------    3 thomas           staff                  96 Jan 13 11:57 cache/exec-credential
45820329       16 -rw-------    1 thomas           staff                5442 Jan 13 11:57 cache/exec-credential/1358261b-ca50-4c35-a2b1-xxx.json

Let's move that to an os-specific, standardized location. The freedesktop spec f.e. defines $XDG_CACHE_HOME for this (https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html). So on linux it would be: ~/.cache/gscloud

@bkircher do you have any ideas on how to make this as compliant as possible. Is there some library we can use?

Upload raw storage images

i'd love to upload my existing kvm-raw vm-images directly as storage into gridscale. best way might be via gscloud instead of webinterface. this would simplify migration of existing vms massively.

thanx and cheers.ivo

Account selection does not work

Having multiple entries in config yaml and selecting with --account flag does not work. Always seems to select the default (or first) account.

Repro:

  • add multiple entries in config file
  • do a gscloud --account second-entry server ls

Expected:

  • when no --account is given: always chose account 'default' if exists, or, if only one exists in config, that one
  • when --account is given, that one
  • when --account is given and that one does not exist in config, an error

Add basic support for IP addresses

Add command to list, remove, create IP -4 and -6 addresses. Add a way to assign them to servers.

Maybe something like

gscloud ip ls # lists all
gscloud ip ls -4 # lists only IPv4
gscloud ip ls -6 # lists only IPv6
gscloud ip rm <id> # delete by ID or
gscloud ip rm <address> # delete by address
gscloud ip create --reverse-dns=example.com --assign-to=<server id> # will pull a IPv4 from pool
gscloud ip create -6 --reverse-dns=example.com --assign-to=<server id> # same with IPv6
# supporting additional flags like
 --name=Example
 --failover=yes

Fix behavior of gscloud-server-create --password

In gscloud-server-create, --password is mandatory when creating with storage. This is not enforced by gscloud but API calls fail if user forgets to give a PW. Actually this is fine but annoyingly late.

Second thing is that --password is not used at all when --with-template is not given. Also makes sense since we don't need to set a root PW if we don't create a new storage from a OS template. But again, this is annoyingly silent on this user "error".

Lastly, maybe we just should remove --password flag oand not allow the user to set passwords themselves. For one thing, thse passwords wouldn't be recorded by shell history anymore (good) and user cannot forget to specify one (good). We could use something like https://github.com/sethvargo/go-password to always generate sufficiently secure passwords and return them after the server (erm, storage) has been created.

Errors in server create cmd is not handled

The error in this line L159 should be handled. And it is better, if the command can be rollbacked when there is an error returned. E.g. if linking a server and a storage fails, the server and the storage should be removed.

Move away from git flow

Ditch git flow, use GitHub regular work flow. Will make releases much easier and we can automate with tools like GoReleaser.

TODO:

  • update CONTRIBUTING.md
  • update release-checklist.md
  • add goreleaser YAML (#73)
  • remote stale release branches from repository (origin/release/*)
  • remove develop branch, make master default

Support `--timeout` flag

Add --timeout flag so we can set timeout when dealing with gs resources. E.g:
./gscloud server --timeout 10m

Improve error messages

Let's improve the error messages. We should be able to give more distinct information to the user, why something might have failed. E.g.:

newKubeConfig := fetchKubeConfigFromProvider(clusterID)
if len(newKubeConfig.Clusters) == 0 || len(newKubeConfig.Users) == 0 {
	fmt.Fprintln(os.Stderr, "Error: Invalid kubeconfig")
	os.Exit(1)
}
c := newKubeConfig.Clusters[0]
u := newKubeConfig.Users[0]

As a user this is quite confusing because it looks like there's something wrong with his local ~/.kube/config, which isn't the case at all. Furthermore, there should be separate messages for both cases, since both seem to have different originating errors. Something like

  • "cluster not found"
  • "invalid user or token" (if we can tell which is the cause be even more detailed)

This should clear out some initial headache and make the first use even more impressive (because gscloud is already awesome).

CHANGETIME in storage list is not shown in a right format

strconv.FormatInt(int64(stor.Properties.ChangeTime.Hour()), 10),

 $gscloud storage ls
ID                                    NAME                                        CAPACITY  CHANGETIME  STATUS
2b2a09c0-b3a7-42fe-abcb-051aaf4c6317  flat-car-test-a                             10        8           active
0d714b68-a1af-4f89-bc73-3bad1251ed93  gsk-ibrahim-internal-test4-master-backup-0  5         6           active
43797a97-a8ca-464a-bfed-7e8bd23ca7c3  gsk-ibrahim-internal-test4-node-pool0-1     32        6           active
05e39636-a22c-4d5e-999f-e532d15c9aba  paas-vm-lb                                  10        12          active

Server doesn't shutdown without force

Works: $ ./gscloud off --force <id>
Doesn't work: $ ./gscloud off <ID>

During the night i wrote some gocode on my rasppi to see how to build for armv7, during tests i noticed one of my test server was still online

  • I’m sure i turned it off the regular way via ./gscloud off <id>
  • Gaved it a try on macOS and Manjaro it doesn't work without force on both systems, to shut down the server.

I must be missing something in the code somewhere.
Can someone else please test it as well?

See : 78388d4

Unify output stream handling

Sometimes we print with fmt. and sometimes it is log.. Maybe redirect to whatever cobra offers here. Anyway, kind of in-transparent. Clean this up.

add `version` subcommand

I think it's neat to have the ability to display the version of a compiled binary. A version subcommand would be canonical to the docker/kubernetes ecosystem, so we should have one, too.

I'd say this can be done by reading the VERSION file on compile time and adding a basic function that prints out the content of mentioned file.

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.