92 Commits

Author SHA1 Message Date
Ruslan Aliev
3e44c42989 Introduce KRM based k8s applier
The KRM based k8s applier solves multiple design problems
which were introduced in previous airshipctl generation,
making apply code and process more clear, reliable and
readable. In particular:
 * k8s applier now is a KRM function and it allows the
   end user to choose or implement desired backend for
   k8s apply operations;
 * the related amount of code was reduced by three times,
   multiple unused and unnecessary structs/interfaces/design
   patterns were removed or rewrited in more clean and efficient
   way;
 * removed cli-utils dependency from airshipctl;
 * fixed several bugs and code issues, such as incorrect printing
   of tables, duplicated unit tests, improper generation and applying
   inventory config map, etc;
 * cli-utils version used in KRM function was bumped to 0.26.0;
 * phases with duplicated k8s resources were removed or fixed;
 * unit test coverage increased to 83.1%;
 * KRM function logs were integrated with klog library which allows
   to observe logs directly from cli-utils and other dependent libs.

Change-Id: Ief509f1d6abefd53caf7fcffc4e36b0319815373
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #646
2021-10-27 08:14:22 +00:00
Ruslan Aliev
3dfb02eb14 Extend poller capabilities
This patch allows to wait for certain state when applying
particular resources.

Change-Id: I064cb49c8971f1edee870bc6c3c3dd1e428c73f0
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #624
2021-09-29 01:42:32 -05:00
Zuul
00d74a4500 Merge "Allow to specify multiple clusters per get-kubeconfig request" 2021-09-18 06:24:55 +00:00
Ruslan Aliev
b67242f532 Add possibility to specify poll interval
Currently, there is no way to specify poll interval for
kubernetes-apply phases, however such possibility exists
in cli-utils API and could be helpful for tuning apply
process.

Change-Id: I605767d589920d0f1e10343afd9672c8d615a46a
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2021-09-13 22:09:16 -05:00
Ruslan Aliev
b8ddc1fe43 Allow to specify multiple clusters per get-kubeconfig request
Change-Id: I1b736a4b9cae4e6e47ddb7909a8fd619518e975c
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #567
2021-08-12 22:45:33 -05:00
Alexey Odinokov
37c2854cce Switching airshipctl and krm-functions to kustomize 4.2.0
Reworked build process of dependent krm functions
to use the latest airshipctl

Change-Id: If4c7f992123b86442980f381ae69fb003f4851e3
2021-07-22 17:06:32 +00:00
Ruslan Aliev
ab55bc5e86 Move clustetctl to KRM
Change-Id: I79ccb7b7c92f27cf6fdaaa540d86db80a0a62b41
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #568
2021-07-17 22:06:43 -05:00
bijayasharma
622d45f3bd Add flags to airshipctl get-kubeconfig cmd
* This commits add --file and --merge flags to
  airshipctl get-kubeconfig cmd

Change-Id: I919d4f068d3ef9bcda6b3a7c9aeb0826a4e5c0d4
Signed-off-by: bijayasharma <vetbijaya@gmail.com>
Relates-To: #495
Closes: #495
2021-06-23 13:41:14 +00:00
Zuul
8d882fcc85 Merge "Enable tolerance to apply timeout errors" 2021-06-19 03:15:30 +00:00
Ruslan Aliev
5fc39a8b54 Enable tolerance to apply timeout errors
This commit allows to tolerate up to three timeout errors that
came from poll requests before interruption of apply process.

Change-Id: I6cb95eba908e62ee44be3338c263b20c7dffc34b
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #579
Closes: #579
2021-06-18 14:17:17 -05:00
Ruslan Aliev
035e371a5e Allow to setup timeout for get kubeconfig request
This PS replaces cluster-api implementation with our own since
it allows to configure timeout.

Change-Id: I5cbba24dd7c6a279fcd2325e904ac7d18348eabf
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #548
Closes: #548
2021-06-13 17:29:10 -05:00
Zuul
55aea51f70 Merge "Move CAPI resources to target-infra namespace" 2021-06-09 17:23:36 +00:00
Matthew Fuller
75429db630 Move CAPI resources to target-infra namespace
Moves CAPI resources in ephemeral cluster from the 'default'
namespace to a new 'target-infra' namespace.

Closes: #551
Change-Id: I419a71baa8e05e7b57b38234d15b955b36951b40
2021-06-03 23:40:00 +00:00
Ruslan Aliev
0c4d8b80bf Allow to configure timeout for k8s client
It would be helpful to have a possibility to configure Timeout
field, as well as others allowed.

Change-Id: I1e0e895b7ca6a17e86a6ad36f405e2538775cbbb
Closes: #553
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2021-05-28 00:28:30 -05:00
Ruslan Aliev
16e5e9f06a Use proper object to create cmdutil factory
MatchVersionFalgs object should be used instead as cli-utils
library suggests, particularly it will allow us to avoid the
issue when airshipctl apply process stuck after Unknown state.

Change-Id: Id6d6ca69a67cb4a500b150a00df538ffffa11eb3
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #552
2021-05-27 12:24:39 -05:00
Kostiantyn Kalynovskyi
bbd9b018dd Use site-wide kubeconfig only on demand
This patchset introduces new field to Phase.Config API object

SiteWideKubeconfig - if set to true, the phase will have access
to all kubeconfigs for each cluster defined in ClusterMap.

By default only kubeconfig of the cluster specified in
Phase.Metadata.ClusterName will be available to the phase executor.

This approach will speed up the deployment process because arishipctl
will not have to look for multiple kubeconfigs when running each phase

Closes: #547

Change-Id: Ic92027ba88d3ce8cb769c254968530037540b8fd
2021-05-17 23:30:21 +00:00
Kostiantyn Kalynovskyi
dbe05585d3 Close events channel on executor level
This will fix a bug, when go routine wasn't finished when program has
exited. Results of the bug was that not all defered statemnets were
executed, which lead to temp kubeconfig not being cleaned up

Relates-To: #541
Closes: #541

Change-Id: If314886d9bed04b2c0f8a5006bc058395f4fdf7a
2021-05-03 15:26:17 +00:00
bijayasharma
e9179ff018 Fix typos in various files
Signed-off-by: bijayasharma <vetbijaya@gmail.com>
Change-Id: Ibe0066e74497c3caecc50e1187abd0bde7955b04
2021-04-21 17:32:31 +00:00
Zuul
9329b9cc21 Merge "Remove redundant logging when building kubeconfig" 2021-03-31 14:48:27 +00:00
Kostiantyn Kalynovskyi
ef19a9e5da Remove redundant logging when building kubeconfig
Closes: #500

Change-Id: I0fed5bf5abd5c3bfd193270b7c418f493746bea4
2021-03-31 09:44:33 +00:00
Ruslan Aliev
e9041a2a22 Reduce the number of unnecessary document.NewBundleByPath() calls
Since document.NewBundleByPath() is pretty resource and time
consuming call (because it invokes kustomize under the hood),
we should avoid unnecessary calls of this function. There are
lots of the same constructor calls of new bundle from phase
bundle root path, mostly in helper, which slows airshipctl
and makes no sense. This patch fixes this problem by storing
phase root bundle variable in helper, which creates only once
during airshipctl execution.

Change-Id: I6b59d440f7ab7a68dc613091dafcc9e82df10eb7
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #488
2021-03-27 12:58:36 -05:00
Ruslan Aliev
92ce88fc29 Allow relative and ~ path for container mount
This patch allow to specify relative and home (~/) path for container
mounts.src field. In case if specified path is not absolute, it will be
created by following pattern: 'targetPath+mounts.src'; in case if path
contains ~/ - it will be properly expanded (it will allow us to mount
~/.airship working directory).

Change-Id: I878094371a2bc4e48216b1d076e466e3d29a86f6
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #484
Closes: #484
2021-03-25 16:41:30 -05:00
Kostiantyn Kalynovskyi
e2d2607586 Kubeconf builder to return single cluster kubeconf
Now if clusterName is specified for kubebuilder, Build() method
will return kubeconfig containing only context for that cluster.
If no clusterName is specified kubeconfig will have contexts of
all clusters that builder can build. This behaviour is similar
to `kubeconfig get` command.

Relates-To: #460

Change-Id: Ib3bebf61bc60430d347ded41b2e31249b11126eb
2021-03-16 15:53:40 +00:00
Kostiantyn Kalynovskyi
6207e2c24d Add multiple kubeconifg sources to ClusterMap
Change ClusterMap API object to support multiple kubeconfig sources
for a cluster. If one kubeconfig source fails, kubeconfig builder
will not fail and move on to the next one. This behaviour will allow
to support cases when ephemeral cluster is not accesible anymore or
when target cluster is not yet accessible.

For more information please read issue #460 in airshipctl github

Relates-To: #460
Related-To: #460

Change-Id: I7cd32f78cd7c4ad8814eac357424c24216f40d76
2021-03-10 18:22:30 +00:00
Dmitry Ukov
1a0ba5647d Uplift cli-utils and cluster-api
Change-Id: I9b46421812dd15c01a250e6102f9c132ce82dd42
2021-03-02 21:52:50 +04:00
Niharika Bhavaraju
90c0116b7f Phase Validation: k8s applier package changes to support Phase Validation sub command
Relates-To: #330

Change-Id: I1503bcef1bc9d91d6897065a7c4418c1aa6181b6
2021-02-24 13:35:50 +00:00
Kostiantyn Kalynovskyi
d9f54b4171 Extend kubeconfig builder
Change-Id: I6724112826a4cc59815b7524bd05af01a9a1d01b
2021-02-10 14:52:39 +00:00
Zuul
621b7758e0 Merge "Link cluster get-kubeconfig cmd with appropriate functionality" 2021-02-01 19:19:06 +00:00
bijayasharma
661ae70fd0 Removed capitalization in Error string message
* This commit will removed capitalizaion in Error message
  and follow the Golang code rule.
* Golang errors should not begin with capitalization:
  https://github.com/golang/go/wiki/CodeReviewComments#error-strings

Signed-off-by: bijayasharma <vetbijaya@gmail.com>
Change-Id: I053cfa9e21ad56b0f30e476ec36320cb7cea4da4
2021-01-26 19:42:08 +00:00
Ruslan Aliev
899bbdbe07 Link cluster get-kubeconfig cmd with appropriate functionality
This patch links cluster get-kubeconfig command call with
appropriate clusterctl functionality, and also replaces old
callbacks and removes outdated implementation.

Change-Id: Ibd0d981985f94497db250c8df3f5675fdec1d2ca
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #374
2021-01-26 11:03:59 -06:00
Zuul
1cb1171fa8 Merge "Remove unnecessary constants" 2021-01-14 19:09:26 +00:00
Kostiantyn Kalynovskyi
eea34fba72 Don't create NS when dry run strategy is specified.
Change-Id: Ib573d51128b0d0cfab0860e89c691b3b06f8c411
2021-01-14 14:53:40 +00:00
Vladimir Kozhukalov
b0d171d0ec Remove unnecessary constants
Change-Id: Ib54ce13e552efb4ac8efe00c18956ed65b46d564
2021-01-14 14:51:12 +00:00
Ruslan Aliev
b85f8fa8f9 Move kubernetes-apply phase executor to a separate package
Having an executor within applier package creates
potential import cycling. This patch moves it to a separate
package which can be used to conveniently store all the executors
at one place.

Change-Id: I68d909489b691e4fb7129446ef9a3fb085f8683c
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #432
2020-12-11 14:09:41 -06:00
Ruslan Aliev
ca71de3951 Move document filesystem to a separate package
In order to widely use filesystem interface in airshipctl
there is need to move it to separate package to avoid
importing unnecessary dependencies from document
package and, as a consequence, possible cyclic dependencies.
 * filesystem moved from document/fs to pkg/fs

Change-Id: I3b6298462f03db43594a9fa26bf23ab7687c5589
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #415
2020-11-30 19:51:30 -06:00
Kostiantyn Kalynovskyi
8567ddf749 Add support for custom kubeconfig contexts
This commit extends cluster map interface to be able to specify
a custom kubeconfig context per cluster in ClusterMap

Related-To: #380
Related-To: #375
Closes: #380

Change-Id: I9a8a26e3a3666e069c243e871f89ae9222228f17
2020-11-02 15:33:02 +00:00
Sirajudeen
afe9121169 Uplift cli-utils from 0.18.1 to 0.20.6
* uplift of cli-utils had changes with signature of Applier.
  So had to update the impacted go code and cleanup the
  unwanted parameters.

Change-Id: I6f3018d1fd4cac2e1a328e50c44ad0f51bb0e16f
Closes: #367
2020-10-21 18:15:03 +00:00
Vladimir Kozhukalov
dc68640389 Phase docs are targetPath + phaseRepo + phase.DocumentEntrypoint
Change-Id: I1d5ea75d1c19eb4ebaf37b28918ccde771bcef85
Relates-To: #356
2020-10-15 13:55:59 +03:00
Ruslan Aliev
fc33287204 Remove kubeconfig from config struct
Change-Id: I5ab8722dd151d9e652e0b20e1d82988cd98505af
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2020-10-07 14:35:07 -05:00
Zuul
e4a2c68d3e Merge "Use BundleFactory instead of bundle in executors" 2020-09-30 14:24:52 +00:00
Kostiantyn Kalynovskyi
e6e56ffa2e Use BundleFactory instead of bundle in executors
This will allow to avoid using nil bundle and performing
additional checks inside the executors

Change-Id: Ia061cccf7e0a7948bbc5c8fce24e0e6f8b3256e1
2020-09-28 19:39:05 -05:00
Sirajudeen
3e4c228638 Add timeout flag for phase run in cli
Syntax:
	airshipctl phase run <PHASE_NAME> --timeout <time_unit>

Exmaple:
	airshipctl phase run initinfra-ephemeral --debug --wait-timeout 1000s

Change-Id: Ic8c699f5302eb482f32aee0e7d7c593df2ed7d3b
2020-09-28 16:58:18 +00:00
Ruslan Aliev
0c736af2e8 Implement render methods
Change-Id: I03b7aad33576eaa9ef7dfaabfb579ac90cc26a12
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2020-09-23 03:06:51 +00:00
Ruslan Aliev
2e85043c20 Fix typos
Change-Id: I0ce87ec00d2b5974cf861d9c9685f23d7d0f5fc1
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2020-09-21 02:49:33 -05:00
Kostiantyn Kalynovskyi
285130106a Use cluster name as context in executors
Change-Id: I4fcf524dd2ff466290b80df7d966f90aa0409471
Relates-To: #342
2020-09-15 12:29:16 -05:00
Kostiantyn Kalynovskyi
410f9c4fd7 Use Helper in clusterctl and kube apply executors
Relates-To: #342

Change-Id: I6f3f9b5aac3877f5738f0ec077c65bcf5acfc54d
2020-09-12 15:21:04 +00:00
Kostiantyn Kalynovskyi
0a7661ab7c Add clustermap object and interface
This commit adds cluster map api object, cluster map
interface and it's implementation built on top of cluster map api
object.

Important note:
ClusterMap interface needs a method to identify namespace of the
cluster, it can't be a part of api object, because real source for
cluster namespace is cluster object from cluster-api upstream lib.
This will need further design discussion on how we will find
cluster-api kind: Cluster object in our manifests. For now, there
is dummy "default" namespace being used

Change-Id: I8175f54abbe77331f0c87c0bde50857ee5c0eb1d
2020-09-09 17:28:45 -05:00
Ruslan Aliev
233bbda0e0 Remove pkg/environment module
This module is no longer needed since all config preloading actions
were moved to config module and global flags are stored within root
level cmd.

Change-Id: I411f6717e5b3d2998706c35a82f1e7f1b2aef3a8
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #327
2020-09-03 23:52:49 -05:00
Ruslan Aliev
88ec55d34b Refactor phase* commands
All the phase commands was refactored for usage with new config
factory. Config object now is being initialized in pkg module on demand,
which provides more flexibility and cleaner code.

Change-Id: I742c39788098c3185ce89936ea81cd461bf97af3
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #327
2020-09-03 23:52:49 -05:00
Ruslan Aliev
a567007199 Refactor cluster* commands
All the cluster commands was refactored for usage with new config
factory. Config object now is being initialized in pkg module on demand,
which provides more flexibility and cleaner code.

Change-Id: I1088ecbce0c34a146a646270404ff206b152d310
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2020-09-03 23:52:49 -05:00