{"id":13463695,"url":"https://github.com/kubespray/kubespray-cli","last_synced_at":"2025-03-25T09:30:59.486Z","repository":{"id":62573752,"uuid":"55240748","full_name":"kubespray/kubespray-cli","owner":"kubespray","description":"Easy to use command line tool for kubernetes deployment with kubespray","archived":false,"fork":false,"pushed_at":"2018-01-30T15:05:16.000Z","size":6067,"stargazers_count":253,"open_issues_count":42,"forks_count":63,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-12T04:47:18.554Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kubespray.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-01T15:05:06.000Z","updated_at":"2025-02-05T13:00:28.000Z","dependencies_parsed_at":"2022-11-03T18:30:22.714Z","dependency_job_id":null,"html_url":"https://github.com/kubespray/kubespray-cli","commit_stats":null,"previous_names":["kubespray/kargo-cli"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubespray%2Fkubespray-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubespray%2Fkubespray-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubespray%2Fkubespray-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubespray%2Fkubespray-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubespray","download_url":"https://codeload.github.com/kubespray/kubespray-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245435069,"owners_count":20614823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T14:00:26.647Z","updated_at":"2025-03-25T09:30:59.170Z","avatar_url":"https://github.com/kubespray.png","language":"Python","readme":"Kubespray wrapper\n=============\n\nThis tool helps to deploy a kubernetes cluster with ansible.\n\n\nExample on GCE:\n[![asciicast](https://asciinema.org/a/065mhh5pzmxcwxgp6evebarvd.png)](https://asciinema.org/a/065mhh5pzmxcwxgp6evebarvd?speed=4)\n\nRequirements\n============\n\n-   **Ansible v2.3 (or newer)**\n-   The current user must have its ssh **public key** installed on the\n    remote servers.\n-   The remote user (option --user) must be in the sudoers with no\n    password\n\nInstallation\n============\n\n### Python pip\n\n    sudo pip2 install kubespray\n\n\nConfig file\n-----------\n\nA config file can be updated (yaml). (default: *~/.kubespray.yml* ) \u003c/br\u003e\nThis file contains default values for some parameters that don't change\nfrequently \u003c/br\u003e\n**Note** these values are **overwritten** by the command line.\n\n\n    # Common options\n    # ---------------\n    # Path where the kubespray ansible playbooks will be installed\n    # Defaults to current user's home directory if not set\n    # kubespray_path: \"/tmp\"\n    # Default inventory path\n    kubespray_git_repo: \"https://github.com/kubernetes-incubator/kubespray.git\"\n    # Logging options\n    loglevel: \"info\"\n\n    # Amazon web services options\n    # ---\n    # aws_access_key: \"\u003ckey\u003e\"\n    # aws_secret_key: \"\u003csecret_key\u003e\"\n    # key_name: \"\u003ckeypair_name\u003e\"\n    # ami: \"\u003caws_ami\u003e\"\n    # masters_instance_type: \"\u003cmasters_instance_type\u003e\"\n    # nodes_instance_type: \"\u003cnodes_instance_type\u003e\"\n    # etcds_instance_type: \"\u003cetcds_instance_type\u003e\"\n    # masters_instance_profile_name: \"\u003cmaster_instance_profile_name\u003e\"\n    # nodes_instance_profile_name: \"\u003cnodes_instance_profile_name\u003e\"\n    # etcds_instance_profile_name: \"\u003cetcds_instance_profile_name\u003e\"\n    # security_group_name: \"\u003csecurity_group_name\u003e\"\n    # security_group_id: \"\u003csecurity_group_id\u003e\"\n    # assign_public_ip: True\n    # vpc_subnet_id: \"\u003cvpc_id\u003e\"\n    # region: \"\u003caws_region\u003e\"\n    # tags:\n    #   - type: k8s\n\n    # OpenStack options\n    # ---\n    # os_auth_url: \"https://\"\n    # os_username: \"k8s\"\n    # os_password: \"secret\"\n    # os_project_name: \"k8s\"\n    # masters_flavor: \"m1.small\"\n    # nodes_flavor: \"m1.small\"\n    # etcds_flavor: \"m1.small\"\n    # image: \"wily-server-cloudimg-amd64\"\n    # network: \"my-network\"\n    # sshkey: \"my-pub-key\"\n    ...\n\nBasic usage\n-----------\n**Note**: You may want to choose the architecture of your cluster. \u003c/br\u003e\nHere are 3 examples:\n* 3 vms, all 3 have etcd installed, all 3 are nodes (running pods), 2 of them run master components\n```\nkubespray [prepare|aws|gce] --nodes 3\n```\n\n![3nodes](https://s32.postimg.org/8q7gns8ut/3nodes.png)\n* 6 vms, 2 are nodes and masters, 1 is node only and a distinct etcd cluster\n```\nkubespray [prepare|aws|gce] --nodes 3 --etcds 3\n```\n\n![3nodes3etcds](https://s32.postimg.org/hphgxcjmt/3nodes_3etcds.png)\n* 8 vms, 2 distinct masters, 3 nodes and 3 etcds\n```\nkubespray [prepare|aws|gce] --nodes 3 --etcds 3 --masters 2\n```\n\n![3nodes3etcds2masters](https://s31.postimg.org/h4gdu4qjv/3nodes_2masters_3etcds.png)\n\nYou should have at least 3 nodes but you can spawn only one instance for\ntests purposes.\n\n### Generate inventory for a baremetal cluster\n\nIf the servers are already available you can use the argument **prepare**\nThe command below will just clone the git repository and creates the\ninventory.\nThe hostvars must be separated by a **comma without spaces**\n\n    kubespray prepare --nodes node1[ansible_ssh_host=10.99.21.1] node2[ansible_ssh_host=10.99.21.2] node3[ansible_ssh_host=10.99.21.3] [--etcds N+] [--masters N+]\n\n### Run instances and generate the inventory on Clouds\n\n\n**AWS**\n\nIn order to create vms on AWS you can either edit the config file *~/.kubespray.yml* or set the options with the argument **aws**\nif the config file is filled with the proper information you just need to run the following command\n\n    kubespray aws --nodes 3 [--etcds N+] [masters N+] [--nodes-instance-type m4.large]\n\nAnother example which download kubespray's repo in a defined directory and set the cluster name\n\n    kubespray aws --nodes 3 -p /tmp/mykubespray --cluster-name foobar\n\n\n**GCE**\n\nIn order to create vms on GCE you can either edit the config file */etc/kubespray/kubespray.yml* or set the options with the argument **gce**\nif the config file is filled with the proper information you just need to run the following command\n\n    kubespray gce --nodes 3\n\nAnother example if you already have a kubespray repository in your home dir\n\n    kubespray gce --nodes 3 --noclone --cluster-name foobar [--nodes-machine-type n1-standard-4]\n\n\n**OpenStack**\n\nIn order to create vms on a OpenStack cluster you can either edit the config file *~/.kubespray.yml* or set the options with the argument **openstack**.\nThe options **network** and **sshkey** are required and need to be created before running kubespray, you can either create them using the OpenStack Dashboard or the OpenStack CLI clients. Running the ansible routines that kubespray will invoke requires to have installed the [openstack cli tools](http://docs.openstack.org/user-guide/common/cli_install_openstack_command_line_clients.html) and openstack [shade](http://docs.openstack.org/infra/shade/installation.html).\n\n\nCreate a network using the OpenStack Neutron client\n\n    # create network\n    $ neutron net-create k8s-network\n\n    Created a new network:\n    +-----------------+--------------------------------------+\n    | Field           | Value                                |\n    +-----------------+--------------------------------------+\n    | admin_state_up  | True                                 |\n    | id              | 18989cb2-d9fc-4abd-85e8-fe5b33df3541 |\n    | mtu             | 0                                    |\n    | name            | k8s-network                          |\n    | router:external | False                                |\n    | shared          | False                                |\n    | status          | ACTIVE                               |\n    | subnets         |                                      |\n    | tenant_id       | 5de2cf232a674b05983b61fdc1ea67aa     |\n    +-----------------+--------------------------------------+\n\n    # create subnet\n    $ neutron subnet-create --name k8s-subnet --dns-nameserver 8.8.8.8 --enable-dhcp --allocation_pool \"start=192.168.0.100,end=192.168.0.200\" k8s-network 192.168.0.0/24\n\n    Created a new subnet:\n    +-------------------+----------------------------------------------------+\n    | Field             | Value                                              |\n    +-------------------+----------------------------------------------------+\n    | allocation_pools  | {\"start\": \"192.168.0.100\", \"end\": \"192.168.0.200\"} |\n    | cidr              | 192.168.0.0/24                                     |\n    | dns_nameservers   |                                                    |\n    | enable_dhcp       | True                                               |\n    | gateway_ip        | 192.168.0.1                                        |\n    | host_routes       |                                                    |\n    | id                | fc5a5436-de3a-4d68-9846-d977d047d6d7               |\n    | ip_version        | 4                                                  |\n    | ipv6_address_mode |                                                    |\n    | ipv6_ra_mode      |                                                    |\n    | name              | k8s-subnet                                         |\n    | network_id        | 18989cb2-d9fc-4abd-85e8-fe5b33df3541               |\n    | subnetpool_id     |                                                    |\n    | tenant_id         | 5de2cf232a674b05983b61fdc1ea67aa                   |\n    +-------------------+----------------------------------------------------+\n\n    # create a router\n    $ neutron router-create k8s-router\n\n    Created a new router:\n    +-----------------------+--------------------------------------+\n    | Field                 | Value                                |\n    +-----------------------+--------------------------------------+\n    | admin_state_up        | True                                 |\n    | external_gateway_info |                                      |\n    | id                    | 69027fa4-239b-4bae-89bc-3040c365ee4d |\n    | name                  | k8s-router                           |\n    | routes                |                                      |\n    | status                | ACTIVE                               |\n    | tenant_id             | 5de2cf232a674b05983b61fdc1ea67aa     |\n    +-----------------------+--------------------------------------+\n\n    # set gateway network, external_network is the name of the external network defined by your OpenStack provider\n    $ neutron router-gateway-set k8s-router external_network\n\n    Set gateway for router k8s-router\n\n    # add k8s-subnet to k8s-router, plug the virtual cable\n    $ neutron router-interface-add k8s-router subnet=k8s-subnet\n\n    Added interface a62ca3b4-3302-45b6-803e-f87a4f43b4b6 to router k8s-router.\n\nUpload a ssh key in order to connect to the vms using the OpenStack Nova client\n\n\n    # import SSH Public Key with name k8s-pub-key\n    $ nova keypair-add --pub-key id_rsa.pub k8s-pub-key\n\n\nOnce the preparation have been completed you can enter the required options to the config file */etc/kubespray/kubespray.yml*:\n\n    ...\n\n    network: \"k8s-network\"\n    sshkey: \"k8s-pub-key\"\n\n    ...\n\n\nIf the config file is filled with the proper information you just need to run the following command\n\n    kubespray openstack --masters 2 --nodes 2 --etcds 3\n\nAnother example if you already have a kubespray repository in your home dir\n\n    kubespray openstack --masters 2 --nodes 2 --etcds 3 --noclone --cluster-name foobar\n\n\n**Add a node to an existing cluster**\nIt's possible to add nodes to a running cluster, \u003c/br\u003e\nthese newly added nodes will act as node only (no etcd, no master components)\n\nAdd a node\n\n    kubespray [aws|gce] --add --nodes 1\n\nThen deploy the cluster with the same options as the running cluster.\n\n\n### Deploy cluster\n\nThe last step is to run the cluster deployment.\n\n**Note**:\n-   default network plugin : flannel (vxlan) default\n-   default kubespray\\_path : \"/home/\\\u003ccurrent\\_user\\\u003e/kubespray\"\n-   inventory path : \"\\\u003ckubespray\\_path\\\u003e/inventory/inventory.cfg\".\n-   The option `--inventory` allows to use an existing inventory (file or dynamic)\n-   On coreos (--coreos) the directory **/opt/bin** must be writable\n- You can use all Ansible's variables with\n`--ansible-opts '-e foo=bar -e titi=toto -vvv'` (the value must be enclosed by simple quotes)\n\nsome examples:\n\nDeploy with the default options on baremetal\n\n    kubespray deploy\n\nDeploy on AWS using a specific kubespray directory and set the api password\n\n    kubespray deploy --aws --passwd secret -p /tmp/mykubespray -n weave\n\nDeploy a kubernetes cluster on CoreOS servers located on GCE\n\n    kubespray deploy -u core -p /kubespray-dc1 --gce --coreos --cluster-name mykube --kube-network 10.42.0.0/16\n","funding_links":[],"categories":["Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubespray%2Fkubespray-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubespray%2Fkubespray-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubespray%2Fkubespray-cli/lists"}