Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pharos init command for cluster.yml bootstrapping #1304

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kke
Copy link
Contributor

@kke kke commented Apr 25, 2019

Fixes #1276

Adds a pharos init subcommand for creating an initial pharos cluster.yml configuration file.

Help

$ pharos init --help
Usage:
    pharos init [OPTIONS]

  Create a Pharos cluster configuration

Options:
    -c, --config FILE             output filename (default: "cluster.yml")
    --defaults                    include all configuration default values
    -m, --master HOST             master host [user@]address[:port]
    -w, --worker HOST             worker host [user@]address[:port]
    -b, --bastion HOST            bastion (ssh proxy) host [user@]address[:port]
    -n, --name NAME               cluster name
    -e, --env KEY=VALUE           host environment variables (can be given multiple times)
    -i, --ssh-key-path PATH       ssh key path
    -h, --help                    print help
    --[no-]color                  colorize output (default: true)
    -v, --version                 print pharos version
    -d, --debug                   enable debug output (default: $DEBUG)

No params:

$ pharos init; cat cluster.yml

-->

# For full configuration reference, see https://pharos.sh/docs/configuration/
---
name: dark-wind-5414

host_defaults: &host_defaults
  user: kimmo
  ssh_key_path: ~/.ssh/id_rsa
  ssh_port: 22
  # environment:
  #   HTTP_PROXY: 192.168.0.1
  # bastion:
  #   address: 192.168.0.1
  #   user: bastion
  #   ssh_key_path: ~/.ssh/id_rsa

hosts:
  - <<: *host_defaults
    address: 10.0.0.1
    user:
    private_address: 172.16.0.1
    role: master
  - <<: *host_defaults
    address: 10.0.0.2
    user:
    private_address: 172.16.0.2
    role: worker

network:
  provider: weave

addons:
  ingress-nginx:
    enabled: true

Pharos::Config defaults:

$ pharos init --defaults; cat cluster.yml

--->

---
name: white-bird-6458
hosts:
- ssh_key_path: "~/.ssh/id_rsa"
  user: kimmo
  address: 10.0.0.1
  private_address: 172.16.0.1
  role: master
- ssh_key_path: "~/.ssh/id_rsa"
  user: kimmo
  address: 10.0.0.2
  private_address: 172.16.0.2
  role: worker
network:
  provider: weave
  service_cidr: 10.96.0.0/12
  pod_network_cidr: 10.32.0.0/12
  node_local_dns_cache: true
  firewalld:
    enabled: false
    open_ports:
    - port: '22'
      protocol: tcp
      roles:
      - "*"
    - port: '80'
      protocol: tcp
      roles:
      - worker
    - port: '443'
      protocol: tcp
      roles:
      - worker
    - port: '6443'
      protocol: tcp
      roles:
      - master
    - port: 30000-32767
      protocol: tcp
      roles:
      - "*"
    - port: 30000-32767
      protocol: udp
      roles:
      - "*"
  weave:
    no_masq_local: false
  calico:
    ipip_mode: Always
    nat_outgoing: true
    environment: {}
    mtu: 1500
  custom: {}
kube_proxy:
  mode: iptables
api: {}
etcd: {}
cloud: {}
authentication:
  token_webhook: {}
  oidc: {}
audit:
  webhook: {}
  file: {}
kubelet:
  read_only_port: false
control_plane:
  use_proxy: false
telemetry:
  enabled: true
pod_security_policy:
  default_policy: 00-pharos-privileged
image_repository: registry.pharos.sh/kontenapharos
addon_paths: []
addons: {}
container_runtime:
  insecure_registries: []

Initialize with ssh user@host and bastion

$ pharos init -m [email protected] -w [email protected]:2444 -w [email protected] -b [email protected]:224; cat cluster.yml

-->

# For full configuration reference, see https://pharos.sh/docs/configuration/
---
name: billowing-river-7649

host_defaults: &host_defaults
  user: vagrant
  ssh_key_path: ~/.ssh/id_rsa
  ssh_port: 22
  # environment:
  #   HTTP_PROXY: 192.168.0.1
  bastion:
    address: 127.0.0.1
    user: bastion
    ssh_port: 224
    # ssh_key_path: ~/.ssh/id_rsa

hosts:
  - <<: *host_defaults
    address: 192.168.100.100
    role: master
  - <<: *host_defaults
    address: 10.0.0.1
    ssh_port: 2444
    role: worker
  - <<: *host_defaults
    address: 10.0.0.2
    user: root
    role: worker

network:
  provider: weave

addons:
  ingress-nginx:
    enabled: true

SSH user@host, bastion + defaults

$ pharos init -m [email protected] -w [email protected]:2444 -w [email protected] -b [email protected]:224 --defaults; cat cluster.yml

-->

---
name: black-snow-4463
hosts:
- ssh_key_path: "~/.ssh/id_rsa"
  bastion:
    address: 127.0.0.1
    user: bastion
    ssh_port: 224
  user: vagrant
  address: 192.168.100.100
  ssh_port:
  role: master
- ssh_key_path: "~/.ssh/id_rsa"
  bastion:
    address: 127.0.0.1
    user: bastion
    ssh_port: 224
  user: vagrant
  address: 10.0.0.1
  ssh_port: 2444
  role: worker
- ssh_key_path: "~/.ssh/id_rsa"
  bastion:
    address: 127.0.0.1
    user: bastion
    ssh_port: 224
  user: vagrant
  address: 10.0.0.2
  ssh_port:
  role: worker
network:
  provider: weave
  service_cidr: 10.96.0.0/12
  pod_network_cidr: 10.32.0.0/12
  node_local_dns_cache: true
  firewalld:
    enabled: false
    open_ports:
    - port: '22'
      protocol: tcp
      roles:
      - "*"
    - port: '80'
      protocol: tcp
      roles:
      - worker
    - port: '443'
      protocol: tcp
      roles:
      - worker
    - port: '6443'
      protocol: tcp
      roles:
      - master
    - port: 30000-32767
      protocol: tcp
      roles:
      - "*"
    - port: 30000-32767
      protocol: udp
      roles:
      - "*"
  weave:
    no_masq_local: false
  calico:
    ipip_mode: Always
    nat_outgoing: true
    environment: {}
    mtu: 1500
  custom: {}

@kke kke added the enhancement New feature or request label Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pharos-cluster init subcommand
1 participant