-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
4,762 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
service_bootstrap() { ruby -- "${BASH_SOURCE%.*}/appliance.rb" bootstrap; } | ||
|
||
service_cleanup() { ruby -- "${BASH_SOURCE%.*}/appliance.rb" cleanup; } | ||
|
||
service_configure() { ruby -- "${BASH_SOURCE%.*}/appliance.rb" configure; } | ||
|
||
service_install() { ruby -- "${BASH_SOURCE%.*}/appliance.rb" install; } | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
AllCops: | ||
Exclude: | ||
- '*_spec.rb' | ||
|
||
Lint/MissingCopEnableDirective: | ||
Enabled: false | ||
|
||
Layout/FirstArrayElementIndentation: | ||
Enabled: false | ||
|
||
Layout/FirstHashElementIndentation: | ||
Enabled: false | ||
|
||
Layout/HashAlignment: | ||
Enabled: false | ||
|
||
Layout/HeredocIndentation: | ||
Enabled: false | ||
|
||
Layout/IndentationWidth: | ||
Enabled: false | ||
|
||
Layout/MultilineMethodCallIndentation: | ||
Enabled: false | ||
|
||
Metrics/BlockLength: | ||
Enabled: false | ||
|
||
Metrics/MethodLength: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'config.rb' | ||
require_relative 'helpers.rb' | ||
|
||
require_relative 'vnf.rb' | ||
require_relative 'kubernetes.rb' | ||
|
||
require_relative 'multus.rb' | ||
require_relative 'calico.rb' | ||
require_relative 'canal.rb' | ||
require_relative 'cilium.rb' | ||
|
||
require_relative 'metallb.rb' | ||
require_relative 'traefik.rb' | ||
require_relative 'longhorn.rb' | ||
require_relative 'cleaner.rb' | ||
|
||
if caller.empty? | ||
case ARGV[0].to_sym | ||
when :install | ||
install_packages PACKAGES | ||
|
||
with_policy_rc_d_disabled do | ||
install_kubernetes | ||
end | ||
|
||
install_metallb | ||
install_traefik | ||
install_longhorn | ||
install_cleaner | ||
|
||
# NOTE: Longhorn images are pulled separately. | ||
pull_addon_images if ONE_SERVICE_AIRGAPPED | ||
|
||
msg :info, 'Installation completed successfully' | ||
|
||
when :configure | ||
prepare_dedicated_storage unless ONEAPP_STORAGE_DEVICE.nil? | ||
|
||
configure_vnf | ||
|
||
if ONE_SERVICE_AIRGAPPED | ||
include_images 'rke2-images-core' | ||
include_images 'rke2-images-multus' if ONEAPP_K8S_MULTUS_ENABLED | ||
include_images 'rke2-images-cilium' if ONEAPP_K8S_CNI_PLUGIN == 'cilium' | ||
|
||
include_images 'one-longhorn' if ONEAPP_K8S_LONGHORN_ENABLED | ||
include_images 'one-metallb' if ONEAPP_K8S_METALLB_ENABLED | ||
include_images 'one-traefik' if ONEAPP_K8S_TRAEFIK_ENABLED | ||
include_images 'one-cleaner' | ||
end | ||
|
||
node = configure_kubernetes( | ||
configure_cni: ->{ | ||
configure_multus if ONEAPP_K8S_MULTUS_ENABLED | ||
configure_calico if ONEAPP_K8S_CNI_PLUGIN == 'calico' | ||
configure_canal if ONEAPP_K8S_CNI_PLUGIN == 'canal' | ||
configure_cilium if ONEAPP_K8S_CNI_PLUGIN == 'cilium' | ||
}, | ||
configure_addons: ->{ | ||
configure_metallb if ONEAPP_K8S_METALLB_ENABLED | ||
|
||
include_manifests 'one-longhorn' if ONEAPP_K8S_LONGHORN_ENABLED | ||
include_manifests 'one-metallb' if ONEAPP_K8S_METALLB_ENABLED | ||
include_manifests 'one-traefik' if ONEAPP_K8S_TRAEFIK_ENABLED | ||
include_manifests 'one-cleaner' | ||
} | ||
) | ||
|
||
if node[:join_worker] | ||
vnf_ingress_setup_https_backend | ||
vnf_ingress_setup_http_backend | ||
end | ||
|
||
msg :info, 'Configuration completed successfully' | ||
|
||
when :bootstrap | ||
puts 'bootstrap_success' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'base64' | ||
require 'yaml' | ||
|
||
require_relative 'config.rb' | ||
require_relative 'helpers.rb' | ||
|
||
def configure_calico(manifest_dir = K8S_MANIFEST_DIR) | ||
msg :info, 'Configure Calico' | ||
|
||
if ONEAPP_K8S_CNI_CONFIG.nil? | ||
msg :info, 'Create Calico CRD config from user-provided ranges' | ||
|
||
documents = YAML.load_stream <<~MANIFEST | ||
--- | ||
apiVersion: helm.cattle.io/v1 | ||
kind: HelmChartConfig | ||
metadata: | ||
name: rke2-calico | ||
namespace: kube-system | ||
spec: | ||
valuesContent: |- | ||
MANIFEST | ||
else | ||
msg :info, 'Use Calico user-provided config' | ||
documents = YAML.load_stream Base64.decode64 ONEAPP_K8S_CNI_CONFIG | ||
end | ||
|
||
msg :info, 'Generate Calico config manifest' | ||
manifest = YAML.dump_stream *documents | ||
file "#{manifest_dir}/rke2-calico-config.yaml", manifest, overwrite: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'base64' | ||
require 'yaml' | ||
|
||
require_relative 'config.rb' | ||
require_relative 'helpers.rb' | ||
|
||
def configure_canal(manifest_dir = K8S_MANIFEST_DIR) | ||
msg :info, 'Configure Canal' | ||
|
||
if ONEAPP_K8S_CNI_CONFIG.nil? | ||
msg :info, 'Create Canal CRD config from user-provided ranges' | ||
|
||
documents = YAML.load_stream <<~MANIFEST | ||
--- | ||
apiVersion: helm.cattle.io/v1 | ||
kind: HelmChartConfig | ||
metadata: | ||
name: rke2-canal | ||
namespace: kube-system | ||
spec: | ||
valuesContent: |- | ||
MANIFEST | ||
else | ||
msg :info, 'Use Canal user-provided config' | ||
documents = YAML.load_stream Base64.decode64 ONEAPP_K8S_CNI_CONFIG | ||
end | ||
|
||
msg :info, 'Generate Canal config manifest' | ||
manifest = YAML.dump_stream *documents | ||
file "#{manifest_dir}/rke2-canal-config.yaml", manifest, overwrite: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'base64' | ||
require 'uri' | ||
require 'yaml' | ||
|
||
require_relative 'config.rb' | ||
require_relative 'helpers.rb' | ||
|
||
def configure_cilium(manifest_dir = K8S_MANIFEST_DIR, endpoint = K8S_CONTROL_PLANE_EP) | ||
msg :info, 'Configure Cilium' | ||
|
||
ep = URI.parse "https://#{endpoint}" | ||
|
||
if ONEAPP_K8S_CNI_CONFIG.nil? | ||
msg :info, 'Create Cilium CRD config from user-provided ranges' | ||
|
||
documents = YAML.load_stream <<~MANIFEST | ||
--- | ||
apiVersion: helm.cattle.io/v1 | ||
kind: HelmChartConfig | ||
metadata: | ||
name: rke2-cilium | ||
namespace: kube-system | ||
spec: | ||
valuesContent: |- | ||
kubeProxyReplacement: strict | ||
k8sServiceHost: "#{ep.host}" | ||
k8sServicePort: #{ep.port} | ||
cni: | ||
chainingMode: "none" | ||
exclusive: false | ||
bgpControlPlane: | ||
enabled: true | ||
--- | ||
apiVersion: cilium.io/v2alpha1 | ||
kind: CiliumLoadBalancerIPPool | ||
metadata: | ||
name: default | ||
namespace: kube-system | ||
spec: | ||
cidrs: {} | ||
MANIFEST | ||
|
||
unless ONEAPP_K8S_CILIUM_RANGES.empty? | ||
ip_address_pool = documents.find do |doc| | ||
doc['kind'] == 'CiliumLoadBalancerIPPool' && doc.dig('metadata', 'name') == 'default' | ||
end | ||
ip_address_pool['spec']['cidrs'] = extract_cilium_ranges.map do |item| | ||
{ 'cidr' => item.join('/') } | ||
end | ||
end | ||
else | ||
msg :info, 'Use Cilium user-provided config' | ||
documents = YAML.load_stream Base64.decode64 ONEAPP_K8S_CNI_CONFIG | ||
end | ||
|
||
msg :info, 'Generate Cilium config manifest' | ||
manifest = YAML.dump_stream *documents | ||
file "#{manifest_dir}/rke2-cilium-config.yaml", manifest, overwrite: true | ||
end | ||
|
||
def extract_cilium_ranges(ranges = ONEAPP_K8S_CILIUM_RANGES) | ||
ranges.compact | ||
.map(&:strip) | ||
.reject(&:empty?) | ||
.map { |item| item.split('/').map(&:strip) } | ||
.reject { |item| item.length > 2 } | ||
.reject { |item| item.map(&:empty?).any? } | ||
.reject { |item| !(ipv4?(item.first) && integer?(item.last)) } | ||
end |
Oops, something went wrong.