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

Feature: CNF Installation (4) Group several manifest into one file #2144

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ shards:

find:
git: https://github.com/cnf-testsuite/find.git
version: 0.1.0+git.commit.129096c08d84adb1b741aa8a5ee132d6f2a87e02
version: 0.1.0

git:
git: https://github.com/cnf-testsuite/git.git
Expand All @@ -29,19 +29,19 @@ shards:
version: 0.12.1

helm:
git: https://github.com/cnf-testsuite/helm.git
git: https://github.com/barmull/helm
version: 1.0.2

icr:
git: https://github.com/crystal-community/icr.git
version: 0.9.0+git.commit.f62bfcdfbe65ee31c46c3d9951cee08ac2e0bee0
version: 0.9.0

k8s_kernel_introspection:
git: https://github.com/cnf-testsuite/k8s_kernel_introspection.git
version: 1.0.3

k8s_netstat:
git: https://github.com/cnf-testsuite/k8s_netstat.git
git: https://github.com/barmull/k8s_netstat
version: 1.0.1

kernel_introspection:
Expand All @@ -62,23 +62,23 @@ shards:

readline:
git: https://github.com/crystal-lang/crystal-readline.git
version: 0.1.1+git.commit.69ecf33d7cad5568d7d19333510cfd9d17cb1bbd
version: 0.1.1

release_manager:
git: https://github.com/cnf-testsuite/release_manager.git
version: 0.1.0+git.commit.a1d7b3568d3112f737ab3ff4a7bae69a6b86970a
version: 0.1.0

retriable:
git: https://github.com/sija/retriable.cr.git
version: 0.2.5

sam:
git: https://github.com/vulk/sam.cr.git
version: 0.4.0+git.commit.4e3b271d31d7fd3c3ca2b0c1ff4943b86dc27021
version: 0.4.0

tar:
git: https://github.com/cnf-testsuite/tar.git
version: 0.1.0+git.commit.ae9bbea1402eded7b411368336653e4ad822003a
version: 0.1.0

totem:
git: https://github.com/icyleaf/totem.git
Expand Down
6 changes: 4 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ dependencies:
github: cnf-testsuite/k8s_kernel_introspection
version: ~> 1.0.3
helm:
github: cnf-testsuite/helm
github: barmull/helm
branch: main
version: ~> 1.0.1
k8s_netstat:
github: cnf-testsuite/k8s_netstat
github: barmull/k8s_netstat
branch: main
version: ~> 1.0.1
release_manager:
github: cnf-testsuite/release_manager
Expand Down
6 changes: 6 additions & 0 deletions src/tasks/cleanup.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ task "samples_cleanup" do |_, args|
)
nil
end
# Remove common_manifest.yaml file
common_manifest_path = "cnfs/common_manifest.yml"
if File.exists?(common_manifest_path)
File.delete(common_manifest_path)
Log.info { "#{common_manifest_path} file deleted successfully." }
end
end

desc "Cleans up the CNF Test Suite helper tools and containers"
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/utils/cnf_installation/install_common.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module CNFInstall
end

def self.cnf_installation_method(config : CNFManager::Config) : Tuple(CNFInstall::InstallMethod, String)
Log.info { "cnf_installation_method: #{config.cnf_config[:install_method]}" }
Log.info { "cnf_installation_method: #{config.cnf_config[:install_method][0]}" }
Log.info { "config_cnf_config: #{config.cnf_config}" }
yml_file_path = config.cnf_config[:source_cnf_file]
parsed_config_file = CNFManager.parsed_config_file(yml_file_path)
Expand Down
37 changes: 37 additions & 0 deletions src/tasks/utils/cnf_installation/manifest.cr
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,42 @@ module CNFInstall
Log.debug { "manifest_containers: #{manifest_yml}" }
manifest_yml.dig?("spec", "template", "spec", "containers")
end

def self.add_manifest_to_file(release_name : String, manifest : String | Tuple(String, String), destination_file = "cnfs/common_manifest.yml")
if File.exists?(destination_file)
File.open(destination_file, "a") do |file|
file.puts manifest
Log.info { "#{release_name} manifest was appended into #{destination_file} file" }
end
else
File.open(destination_file, "w") do |file|
file.puts manifest
Log.info { "Created #{destination_file} file with #{release_name} manifest." }
end
end
end

def self.generate_manifest(config, release_name, namespace)
install_method = CNFInstall.cnf_installation_method(config)
case install_method[0]
when CNFInstall::InstallMethod::ManifestDirectory
destination_cnf_dir = config.cnf_config[:destination_cnf_dir]
manifest_directory = config.cnf_config[:manifest_directory]
list_of_manifests = manifest_file_list( destination_cnf_dir + "/" + manifest_directory )
list_of_manifests.each do |manifest_path|
manifest = File.read(manifest_path)
add_manifest_to_file(release_name: release_name, manifest: manifest)
end

when CNFInstall::InstallMethod::HelmChart, CNFInstall::InstallMethod::HelmDirectory
begin
generated_manifest = Helm.generate_manifest(release_name, namespace)
add_manifest_to_file(release_name: release_name, manifest: generated_manifest)
rescue ex : Helm::ManifestGenerationError
Log.error { ex.message.colorize(:red) }
exit 1
end
end
end
end
end
4 changes: 4 additions & 0 deletions src/tasks/utils/cnf_manager.cr
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,10 @@ module CNFManager
#TODO call kubectl apply on file
KubectlClient::Apply.file(configmap_path)
# TODO when uninstalling, remove config map

#Generating manifest from installed CNF
CNFInstall::Manifest.generate_manifest(config, release_name, deployment_namespace)

ensure
#todo uninstall/reinstall clustertools because of tshark bug
end
Expand Down
Loading