Skip to content

Commit

Permalink
added upstream istio flavor (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
deva26 authored Feb 15, 2021
1 parent 0a3bd74 commit 398ae39
Show file tree
Hide file tree
Showing 21 changed files with 132 additions and 38 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Considering that some of Service-Mesh customers needs to support elevated securi

- _tetrate_ tracks the upstream Istio and may have additional patches applied
- _tetratefips_ a FIPS compliant version of tetrate flavor
- _istio_ is upstream built Istio

The above functionality is achieved via elegant transparent approach, where the existing setup and tools are fully leveraged to provide additional functionality and enterprise desired feature sets and controls:

Expand Down
2 changes: 1 addition & 1 deletion api/manifest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ message Manifest {

message IstioDistribution {
// Distributions are tagged with `x.y.z-${flavor}-v${flavor_version}` where
// - ${flavor} is either "tetrate" or "tetratefips"
// - ${flavor} is either "tetrate" or "tetratefips" or istio
// - ${flavor_version} is ""numeric"" and the version of that distribution
string version = 1;
string flavor = 2; // note that intentionally use string instead of enum here
Expand Down
13 changes: 8 additions & 5 deletions api/manifest_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
const (
IstioDistributionFlavorTetrate = "tetrate"
IstioDistributionFlavorTetrateFIPS = "tetratefips"
IstioDistributionFlavorIstio = "istio"
)

func (x *Manifest) GetEOLDates() (map[string]time.Time, error) {
Expand Down Expand Up @@ -70,7 +71,9 @@ func (x *IstioDistribution) Group() (string, error) {
return fmt.Sprintf("%s.%s-%s", ts[0], ts[1], x.Flavor), nil
}

func (x *IstioDistribution) IsOfficial() bool {
func (x *IstioDistribution) IsUpstream() bool {
// manifest.json denotes upstream by flavor 'istio'. Whereas the actual upstream images
// in the cluster is of the form 'x.y.z' with no flavor set
return x.Flavor == ""
}

Expand Down Expand Up @@ -108,8 +111,8 @@ func (x *IstioDistribution) GreaterThan(y *IstioDistribution) (bool, error) {

func IstioDistributionFromString(in string) (*IstioDistribution, error) {
if !strings.Contains(in, "-") {
// handle the official version schema: 'x.y.z'
if err := verifyOfficialVersionString(in); err != nil {
// handle the upstream version schema: 'x.y.z'
if err := verifyUpstreamVersionString(in); err != nil {
return nil, err
}

Expand All @@ -121,7 +124,7 @@ func IstioDistributionFromString(in string) (*IstioDistribution, error) {
return nil, fmt.Errorf("invalid version schema: %s", in)
}

if err := verifyOfficialVersionString(parts[0]); err != nil {
if err := verifyUpstreamVersionString(parts[0]); err != nil {
return nil, err
}

Expand All @@ -143,7 +146,7 @@ func parseFlavor(in string) (string, int64, error) {
return flavor, flavorVersion, nil
}

func verifyOfficialVersionString(in string) error {
func verifyUpstreamVersionString(in string) error {
ts := strings.Split(in, ".")
if len(ts) != 3 {
return fmt.Errorf("invalid vesion: cannot parse %s in the form of 'x.y.z'", in)
Expand Down
57 changes: 53 additions & 4 deletions api/manifest_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ func TestIstioDistribution_ToString(t *testing.T) {
},
exp: "1.7.7-tetratefips-v15",
},
{
in: &IstioDistribution{
Version: "1.8.3",
Flavor: IstioDistributionFlavorIstio,
FlavorVersion: 0,
},
exp: "1.8.3-istio-v0",
},
} {
assert.Equal(t, c.exp, c.in.ToString())
}
Expand Down Expand Up @@ -107,6 +115,14 @@ func TestIstioDistributionEqual(t *testing.T) {
},
exp: true,
},
{
in: &IstioDistribution{
Version: "1.8.3",
Flavor: IstioDistributionFlavorIstio,
FlavorVersion: 0,
},
exp: false,
},
} {
assert.Equal(t, c.exp, c.in.Equal(operand))
}
Expand Down Expand Up @@ -153,17 +169,18 @@ func TestIstioDistribution_Group(t *testing.T) {
}{
{exp: "1.3-tetrate", in: &IstioDistribution{Version: "1.3.1", Flavor: "tetrate"}},
{exp: "1.7-tetratefips", in: &IstioDistribution{Version: "1.7.6", Flavor: "tetratefips"}},
{exp: "1.8-istio", in: &IstioDistribution{Version: "1.8.3", Flavor: "istio"}},
} {
actual, err := c.in.Group()
require.NoError(t, err)
assert.Equal(t, c.exp, actual)
}
}

func TestIstioDistribution_IsOfficial(t *testing.T) {
assert.True(t, (&IstioDistribution{Flavor: ""}).IsOfficial())
assert.False(t, (&IstioDistribution{Flavor: "tetrate"}).IsOfficial())
assert.False(t, (&IstioDistribution{Flavor: "tetratefips"}).IsOfficial())
func TestIstioDistribution_IsUpstream(t *testing.T) {
assert.True(t, (&IstioDistribution{Flavor: "istio"}).IsUpstream())
assert.False(t, (&IstioDistribution{Flavor: "tetrate"}).IsUpstream())
assert.False(t, (&IstioDistribution{Flavor: "tetratefips"}).IsUpstream())
}

func TestIstioDistribution_GreaterThan(t *testing.T) {
Expand Down Expand Up @@ -204,6 +221,7 @@ func TestIstioDistribution_Equal(t *testing.T) {
{Version: "1.2.300", Flavor: "tetrate", FlavorVersion: 4},
{Version: "1.2.3", Flavor: "tetratefips", FlavorVersion: 4},
{Version: "1.2.3", Flavor: "tetrate", FlavorVersion: 1},
{Version: "1.2.3", Flavor: "istio", FlavorVersion: 4},
} {
require.False(t, base.Equal(c), fmt.Sprintf("%d-th", i))
}
Expand All @@ -220,6 +238,8 @@ func TestIstioDistributionFromString(t *testing.T) {
exp: &IstioDistribution{Version: "1.7.3", Flavor: "tetrate", FlavorVersion: 0}},
{in: "1.1000.3-tetratefips-v1",
exp: &IstioDistribution{Version: "1.1000.3", Flavor: "tetratefips", FlavorVersion: 1}},
{in: "1.8.3-istio-v0",
exp: &IstioDistribution{Version: "1.8.3", Flavor: "istio", FlavorVersion: 0}},
{in: "1.7.30-tetratefips-v100",
exp: &IstioDistribution{Version: "1.7.30", Flavor: "tetratefips", FlavorVersion: 100}},
{in: "2001.7.3-tetrate-v0",
Expand Down Expand Up @@ -253,6 +273,7 @@ func Test_parseFlavor(t *testing.T) {
}{
{in: "tetrate-v0", flavor: "tetrate", flavorVersion: 0},
{in: "tetratefips-v100", flavor: "tetratefips", flavorVersion: 100},
{in: "istio-v0", flavor: "istio", flavorVersion: 0},
} {
flavor, flavorVersion, err := parseFlavor(c.in)
require.NoError(t, err)
Expand Down Expand Up @@ -285,6 +306,13 @@ func TestGetLatestDistribution(t *testing.T) {
name: "ok",
maniest: &Manifest{
IstioDistributions: []*IstioDistribution{
{
Version: "1.8.3",
Flavor: IstioDistributionFlavorIstio,
FlavorVersion: 0,
K8SVersions: []string{"1.17"},
IsSecurityPatch: false,
},
{
Version: "1.8.2",
Flavor: IstioDistributionFlavorTetrateFIPS,
Expand Down Expand Up @@ -349,6 +377,13 @@ func TestGetLatestDistribution(t *testing.T) {
K8SVersions: []string{"1.16"},
IsSecurityPatch: false,
},
{
Version: "1.8.3",
Flavor: IstioDistributionFlavorIstio,
FlavorVersion: 0,
K8SVersions: []string{"1.16"},
IsSecurityPatch: false,
},
},
},
current: &IstioDistribution{
Expand Down Expand Up @@ -392,6 +427,13 @@ func TestGetLatestDistribution(t *testing.T) {
K8SVersions: []string{"1.16"},
IsSecurityPatch: false,
},
{
Version: "1.8.3",
Flavor: IstioDistributionFlavorIstio,
FlavorVersion: 0,
K8SVersions: []string{"1.18"},
IsSecurityPatch: false,
},
},
},
current: &IstioDistribution{
Expand Down Expand Up @@ -435,6 +477,13 @@ func TestGetLatestDistribution(t *testing.T) {
K8SVersions: []string{"1.16"},
IsSecurityPatch: true,
},
{
Version: "1.8.4",
Flavor: IstioDistributionFlavorIstio,
FlavorVersion: 0,
K8SVersions: []string{"1.17"},
IsSecurityPatch: true,
},
},
},
current: &IstioDistribution{
Expand Down
2 changes: 1 addition & 1 deletion cmd/check_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ getistio check-upgrade
- There is the available patch for the minor version 1.7-tetrate. We recommend upgrading all 1.7-tetrate versions -> 1.7.4-tetrate-v1
- There is the available patch for the minor version 1.8-tetrate which includes **security upgrades**. We strongly recommend upgrading all 1.8-tetrate versions -> 1.8.1-tetrate-v1
In the above example, we call names in the form of x.y-${flavor} "minor version", where x.y is Istio's official minor and ${flavor} is the flavor of the distribution.
In the above example, we call names in the form of x.y-${flavor} "minor version", where x.y is Istio's upstream minor and ${flavor} is the flavor of the distribution.
Please refer to 'getistio fetch --help' or 'getistio list --help' for more information.`,
PreRunE: func(cmd *cobra.Command, args []string) error {
if getistio.GetActiveConfig().IstioDistribution == nil {
Expand Down
5 changes: 4 additions & 1 deletion cmd/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ $ getistio fetch --version 1.7.4 --flavor tetratefips
# Fetch the latest "tetrate flavored" istioctl of version=1.7.4
$ getistio fetch --version 1.7.4
# Fetch the istioctl of version=1.8.3 flavor=istio flavor-version=0
$ getistio fetch --version 1.8.3 --flavor istio
# Fetch the latest "tetrate flavored" istioctl
Expand Down Expand Up @@ -95,7 +98,7 @@ For more information, please refer to "getistio list --help" command.
flags := cmd.Flags()
flags.SortFlags = false
flags.StringVarP(&flagVersion, "version", "", "", "Version of istioctl e.g. \"--version 1.7.4\"")
flags.StringVarP(&flagFlavor, "flavor", "", "", "Flavor of istioctl, e.g. \"--flavor tetrate\" or --flavor tetratefips\"")
flags.StringVarP(&flagFlavor, "flavor", "", "", "Flavor of istioctl, e.g. \"--flavor tetrate\" or --flavor tetratefips\" or --flavor istio\"")
flags.IntVarP(&flagFlavorVersion, "flavor-version", "", -1, "Version of the flavor, e.g. \"--version 1\"")
return cmd
}
11 changes: 6 additions & 5 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS
The following is the explanation of each column:
[ISTIO VERSION]
The official tagged version of Istio on which the distribution is built.
The upstream tagged version of Istio on which the distribution is built.
[FLAVOR]
The kind of the distribution. As of now, there's one flavor which is called "tetrate",
and "tetratefips" flavor will be added shortly.
The kind of the distribution. As of now, there are three flavors "tetrate",
"tetratefips" and "istio".
- "tetrate" flavor equals the official Istio except it is built by Tetrate.
- "tetrate" flavor equals the upstream Istio except it is built by Tetrate.
- "tetratefips" flavor is FIPS-compliant, and can be used for installing FIPS-compliant control plain and data plain built by Tetrate.
- "istio" flavor is the upstream build. Flavor version for upstream build will always be '0'
[FLAVOR VERSION]
The flavor's version. A flavor version 0 maps to the distribution that is built on
exactly the same source code of the corresponding official Istio version.
exactly the same source code of the corresponding upstream Istio version.
[K8S VERSIONS]
Supported k8s versions for the distribution
Expand Down
2 changes: 1 addition & 1 deletion cmd/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ getistio prune --version 1.7.4 --flavor tetrate --flavor-version 0
flags := cmd.Flags()
flags.SortFlags = false
flags.StringVarP(&flagVersion, "version", "", "", "Version of istioctl e.g. 1.7.4")
flags.StringVarP(&flagFlavor, "flavor", "", "", "Flavor of istioctl, e.g. \"tetrate\" or \"tetratefips\"")
flags.StringVarP(&flagFlavor, "flavor", "", "", "Flavor of istioctl, e.g. \"tetrate\" or \"tetratefips\" or \"istio\"")
flags.IntVarP(&flagFlavorVersion, "flavor-version", "", -1, "Version of the flavor, e.g. 1")
return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ getistio switch --version 1.7.4 --flavor tetrate --flavor-version=1`,
flags := cmd.Flags()
flags.SortFlags = false
flags.StringVarP(&flagVersion, "version", "", "", "Version of istioctl e.g. 1.7.4")
flags.StringVarP(&flagFlavor, "flavor", "", "", "Flavor of istioctl, e.g. \"tetrate\" or \"tetratefips\"")
flags.StringVarP(&flagFlavor, "flavor", "", "", "Flavor of istioctl, e.g. \"tetrate\" or \"tetratefips\" or \"istio\"")
flags.IntVarP(&flagFlavorVersion, "flavor-version", "", -1, "Version of the flavor, e.g. 1")

_ = cmd.MarkFlagRequired("version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $ getistio check-upgrade
- There is the available patch for the minor version 1.7-tetrate. We recommend upgrading all 1.7-tetrate versions -> 1.7.4-tetrate-v1
- There is the available patch for the minor version 1.8-tetrate which includes **security upgrades**. We strongly recommend upgrading all 1.8-tetrate versions -> 1.8.1-tetrate-v1
In the above example, we call names in the form of x.y-${flavor} "minor version", where x.y is Istio's official minor and ${flavor} is the flavor of the distribution.
In the above example, we call names in the form of x.y-${flavor} "minor version", where x.y is Istio's upstream minor and ${flavor} is the flavor of the distribution.
Please refer to 'getistio fetch --help' or 'getistio list --help' for more information.
```

Expand Down
5 changes: 4 additions & 1 deletion doc/en/getistio-cli/reference/getistio_fetch/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ $ getistio fetch --version 1.7.4 --flavor tetratefips
# Fetch the latest "tetrate flavored" istioctl of version=1.7.4
$ getistio fetch --version 1.7.4
# Fetch the istioctl of version=1.8.3 flavor=istio flavor-version=0
$ getistio fetch --version 1.8.3 --flavor istio
# Fetch the latest "tetrate flavored" istioctl
Expand All @@ -50,7 +53,7 @@ For more information, please refer to "getistio list --help" command.

```
--version string Version of istioctl e.g. "--version 1.7.4"
--flavor string Flavor of istioctl, e.g. "--flavor tetrate" or --flavor tetratefips"
--flavor string Flavor of istioctl, e.g. "--flavor tetrate" or --flavor tetratefips" or --flavor istio"
--flavor-version int Version of the flavor, e.g. "--version 1" (default -1)
-h, --help help for fetch
```
Expand Down
11 changes: 6 additions & 5 deletions doc/en/getistio-cli/reference/getistio_list/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS
The following is the explanation of each column:
[ISTIO VERSION]
The official tagged version of Istio on which the distribution is built.
The upstream tagged version of Istio on which the distribution is built.
[FLAVOR]
The kind of the distribution. As of now, there's one flavor which is called "tetrate",
and "tetratefips" flavor will be added shortly.
The kind of the distribution. As of now, there are three flavors "tetrate",
"tetratefips" and "istio".
- "tetrate" flavor equals the official Istio except it is built by Tetrate.
- "tetrate" flavor equals the upstream Istio except it is built by Tetrate.
- "tetratefips" flavor is FIPS-compliant, and can be used for installing FIPS-compliant control plain and data plain built by Tetrate.
- "istio" flavor is the upstream build. Flavor version for upstream build will always be '0'
[FLAVOR VERSION]
The flavor's version. A flavor version 0 maps to the distribution that is built on
exactly the same source code of the corresponding official Istio version.
exactly the same source code of the corresponding upstream Istio version.
[K8S VERSIONS]
Supported k8s versions for the distribution
Expand Down
2 changes: 1 addition & 1 deletion doc/en/getistio-cli/reference/getistio_prune/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $ getistio prune --version 1.7.4 --flavor tetrate --flavor-version 0

```
--version string Version of istioctl e.g. 1.7.4
--flavor string Flavor of istioctl, e.g. "tetrate" or "tetratefips"
--flavor string Flavor of istioctl, e.g. "tetrate" or "tetratefips" or "istio"
--flavor-version int Version of the flavor, e.g. 1 (default -1)
-h, --help help for prune
```
Expand Down
2 changes: 1 addition & 1 deletion doc/en/getistio-cli/reference/getistio_switch/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ getistio switch --version 1.7.4 --flavor tetrate --flavor-version=1

```
--version string Version of istioctl e.g. 1.7.4
--flavor string Flavor of istioctl, e.g. "tetrate" or "tetratefips"
--flavor string Flavor of istioctl, e.g. "tetrate" or "tetratefips" or "istio"
--flavor-version int Version of the flavor, e.g. 1 (default -1)
-h, --help help for switch
```
Expand Down
1 change: 1 addition & 0 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func list(t *testing.T) {
require.NoError(t, cmd.Run())

exp := `ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS
1.8.3 istio 0 1.16,1.17,1.18
*1.8.2 tetrate 0 1.16,1.17,1.18
1.8.2 tetratefips 0 1.16,1.17,1.18
1.8.1 tetrate 0 1.16,1.17,1.18
Expand Down
14 changes: 14 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
"1.6": "2020-11-21"
},
"istio_distributions": [
{
"version": "1.8.3",
"flavor": "istio",
"flavor_version": 0,
"k8s_versions": [
"1.16",
"1.17",
"1.18"
],
"release_notes": [
"https://istio.io/latest/news/releases/1.8.x/announcing-1.8.2/"
],
"is_security_patch": false
},
{
"version": "1.8.2",
"flavor": "tetrate",
Expand Down
6 changes: 3 additions & 3 deletions src/checkupgrade/check_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ func getDataPlaneVersions(info *[]istioversion.ProxyInfo) (map[string]*api.Istio
func findLowestPatchVersionsInGroup(in []*api.IstioDistribution) (map[string]*api.IstioDistribution, error) {
ret := make(map[string]*api.IstioDistribution, len(in))
for _, d := range in {
if d.IsOfficial() {
logger.Warnf("the official istio distributions are not supported by check-upgrade command: %s. "+
"Please install distributions listed in `getistio list` command\n", d.Version)
if d.IsUpstream() {
logger.Warnf("the upstream istio distributions are not supported by check-upgrade command: %s. "+
"Please install distributions with tetrate flavor listed in `getistio list` command\n", d.Version)
continue
}

Expand Down
Loading

0 comments on commit 398ae39

Please sign in to comment.