Skip to content

Commit a7e2db1

Browse files
Bye linkerd (aka. unlinked) (#604)
* Remove legacy and linkerd code * Remove some dead code and fix some deprecations * upkeep: Maps har egen copy-funksjon --------- Co-authored-by: Kyrre Havik <[email protected]>
1 parent b7543f6 commit a7e2db1

File tree

77 files changed

+20
-903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+20
-903
lines changed

charts/naiserator/Feature.yaml

-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dependencies:
55
environmentKinds:
66
- tenant
77
- onprem
8-
- legacy
98
values:
109
imageTag:
1110
displayName: Image tag
@@ -53,10 +52,6 @@ values:
5352
displayName: Enable Azure AD for applications
5453
config:
5554
type: bool
56-
naiserator.features.linkerd:
57-
displayName: Enable Linkerd annotations
58-
config:
59-
type: bool
6055
naiserator.doc-url:
6156
computed:
6257
template: |
@@ -93,13 +88,6 @@ values:
9388
displayName: Enable Kafka for applications
9489
computed:
9590
template: '{{ne .Env.aiven_project ""}}'
96-
naiserator.features.legacy-gcp:
97-
description: Configure Naiserator to work with legacy GCP clusters (override mapping for migration)
98-
displayName: Enable legacy GCP mode
99-
computed:
100-
template: '{{eq .Kind "legacy"}}'
101-
config:
102-
type: bool
10391
naiserator.features.nav-ca-bundle:
10492
displayName: Enable NAV CA bundle
10593
config:
@@ -215,34 +203,29 @@ values:
215203
type: string
216204
ignoreKind:
217205
- tenant
218-
- legacy
219206
naiserator.proxy.exclude:
220207
config:
221208
type: string
222209
ignoreKind:
223210
- tenant
224-
- legacy
225211
naiserator.vault.address:
226212
required: true
227213
config:
228214
type: string
229215
ignoreKind:
230216
- tenant
231-
- legacy
232217
naiserator.vault.auth-path:
233218
required: true
234219
config:
235220
type: string
236221
ignoreKind:
237222
- tenant
238-
- legacy
239223
naiserator.vault.kv-path:
240224
required: true
241225
config:
242226
type: string
243227
ignoreKind:
244228
- tenant
245-
- legacy
246229
naiserator.image-pull-secrets:
247230
description: List of image pull secrets to use for pulling images
248231
config:

charts/naiserator/values.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ naiserator:
3737
influx-credentials: false
3838
jwker: false
3939
kafkarator: false
40-
legacy-gcp: false
41-
linkerd: false
4240
maskinporten: false
4341
nav-ca-bundle: false
4442
network-policy: true

hack/tilt-naiserator-config.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ features:
1414
influx-credentials: false
1515
jwker: false
1616
kafkarator: false
17-
legacy-gcp: false
18-
linkerd: false
1917
maskinporten: false
2018
nav-ca-bundle: false
2119
network-policy: false

pkg/generators/application.go

-5
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ func (g *Application) Prepare(ctx context.Context, source resource.Source, kube
102102
return nil, err
103103
}
104104

105-
// Create Linkerd resources only if feature is enabled and namespace is Linkerd-enabled
106-
if g.Config.Features.Linkerd && namespace.Annotations["linkerd.io/inject"] == "enabled" {
107-
o.Linkerd = true
108-
}
109-
110105
o.Team = app.GetNamespace()
111106

112107
return o, nil

pkg/generators/config.go

-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type Options struct {
1717
GoogleProjectID string
1818
GoogleTeamProjectID string
1919
Image string
20-
Linkerd bool
2120
NumReplicas int32
2221
Team string
2322
SqlInstance SqlInstance
@@ -35,11 +34,6 @@ func (o *Options) SqlInstanceHasPrivateIpInSharedVpc() bool {
3534
return o.SqlInstance.hasPrivateIpInSharedVpc
3635
}
3736

38-
func (o *Options) IsLinkerdEnabled() bool {
39-
// not o.Config.Features - this flag is detected in Prepare()
40-
return o.Linkerd
41-
}
42-
4337
func (o *Options) GetAPIServerIP() string {
4438
return o.Config.ApiServerIp
4539
}
@@ -60,10 +54,6 @@ func (o *Options) IsNetworkPolicyEnabled() bool {
6054
return o.Config.Features.NetworkPolicy
6155
}
6256

63-
func (o *Options) IsLegacyGCP() bool {
64-
return o.Config.Features.LegacyGCP
65-
}
66-
6757
func (o *Options) IsCNRMEnabled() bool {
6858
return o.Config.Features.CNRM
6959
}

pkg/generators/naisjob.go

-5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ func (g *Naisjob) Prepare(ctx context.Context, source resource.Source, kube clie
7575
return nil, err
7676
}
7777

78-
// Create Linkerd resources only if feature is enabled and namespace is Linkerd-enabled
79-
if g.Config.Features.Linkerd && namespace.Annotations["linkerd.io/inject"] == "enabled" {
80-
o.Linkerd = true
81-
}
82-
8378
o.Team = job.GetNamespace()
8479

8580
return o, nil

pkg/naiserator/config/config.go

-6
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ type Features struct {
5858
InfluxCredentials bool `json:"influx-credentials"`
5959
Jwker bool `json:"jwker"`
6060
Kafkarator bool `json:"kafkarator"`
61-
LegacyGCP bool `json:"legacy-gcp"`
62-
Linkerd bool `json:"linkerd"`
6361
Maskinporten bool `json:"maskinporten"`
6462
NAVCABundle bool `json:"nav-ca-bundle"`
6563
NetworkPolicy bool `json:"network-policy"`
@@ -206,15 +204,13 @@ const (
206204
FeaturesJwker = "features.jwker"
207205
FeaturesCNRM = "features.cnrm"
208206
FeaturesKafkarator = "features.kafkarator"
209-
FeaturesLinkerd = "features.linkerd"
210207
FeaturesMaskinporten = "features.maskinporten"
211208
FeaturesNetworkPolicy = "features.network-policy"
212209
FeaturesPrometheusOperator = "features.prometheus-operator"
213210
FeaturesTexas = "features.texas"
214211
FeaturesVault = "features.vault"
215212
FeaturesWebhook = "features.webhook"
216213
FeaturesWonderwall = "features.wonderwall"
217-
FeaturesLegacyGCP = "features.legacy-gcp"
218214
FQDNPolicyEnabled = "fqdn-policy.enabled"
219215
GoogleCloudSQLProxyContainerImage = "google-cloud-sql-proxy-container-image"
220216
GoogleProjectId = "google-project-id"
@@ -295,7 +291,6 @@ func init() {
295291
flag.String(GoogleCloudSQLProxyContainerImage, "", "Docker image of Cloud SQL Proxy container")
296292
flag.String(ApiServerIp, "", "IP to master in GCP, e.g. 172.16.0.2/32 for GCP")
297293
flag.String(NaisNamespace, "nais-system", "namespace where nais resources are deployed")
298-
flag.Bool(FeaturesLinkerd, false, "enable creation of Linkerd-specific resources")
299294
flag.StringSlice(
300295
FeaturesAccessPolicyNotAllowedCIDRs, []string{""},
301296
"CIDRs that should not be included within the allowed IP Block rule for network policy",
@@ -311,7 +306,6 @@ func init() {
311306
flag.Bool(FeaturesMaskinporten, false, "enable creation of Maskinporten client resources and secret injection")
312307
flag.Bool(FeaturesWebhook, false, "enable admission webhook server")
313308
flag.Bool(FeaturesPrometheusOperator, false, "enable Prometheus Operator")
314-
flag.Bool(FeaturesLegacyGCP, false, "enable legacy GCP resources")
315309
flag.Bool(FeaturesWonderwall, false, "enable Wonderwall sidecar")
316310
flag.Bool(FeaturesTexas, false, "enable token exchange as a sidecar/service")
317311
flag.Bool(FQDNPolicyEnabled, false, "enable FQDN policies")

pkg/resourcecreator/azure/azureadapplication.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/nais/liberator/pkg/namegen"
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
"k8s.io/apimachinery/pkg/util/validation"
13-
"k8s.io/utils/pointer"
13+
"k8s.io/utils/ptr"
1414

1515
"github.com/nais/naiserator/pkg/resourcecreator/accesspolicy"
1616
"github.com/nais/naiserator/pkg/resourcecreator/pod"
@@ -124,7 +124,7 @@ func sidecar(source Source, ast *resource.Ast, config Config, azureApp *nais_io_
124124
azureApp.Spec.LogoutUrl = util.AppendPathToIngress(ingresses[0], wonderwall.FrontChannelLogoutPath)
125125

126126
// ensure that singlePageApplication is _disabled_ if sidecar is enabled
127-
azureApp.Spec.SinglePageApplication = pointer.Bool(false)
127+
azureApp.Spec.SinglePageApplication = ptr.To(false)
128128

129129
s := source.GetAzure().GetSidecar()
130130
return wonderwall.Create(source, ast, config, wonderwall.Configuration{

pkg/resourcecreator/google/bigquery/bigquery.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/nais/naiserator/pkg/util"
1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1515
"k8s.io/apimachinery/pkg/util/validation"
16-
"k8s.io/utils/pointer"
16+
"k8s.io/utils/ptr"
1717
)
1818

1919
type Source interface {
@@ -67,7 +67,7 @@ func iAMPolicyMember(source resource.Source, bigqueryDataset *google_nais_io_v1.
6767
Role: "roles/bigquery.jobUser",
6868
ResourceRef: google_iam_crd.ResourceRef{
6969
Kind: "Project",
70-
Name: pointer.StringPtr(""),
70+
Name: ptr.To(""),
7171
},
7272
},
7373
}
@@ -114,4 +114,4 @@ func createDataset(source resource.Source, bigQuerySpec nais_io_v1.CloudBigQuery
114114
},
115115
},
116116
}, nil
117-
}
117+
}

pkg/resourcecreator/google/sql/user.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"strings"
66

7-
nais "github.com/nais/liberator/pkg/apis/nais.io/v1"
87
nais_io_v1 "github.com/nais/liberator/pkg/apis/nais.io/v1"
98
googlesqlcrd "github.com/nais/liberator/pkg/apis/sql.cnrm.cloud.google.com/v1beta1"
109
"github.com/nais/liberator/pkg/namegen"
@@ -34,7 +33,7 @@ const (
3433
type GoogleSqlUser struct {
3534
Username string
3635
AppName string
37-
DB *nais.CloudSqlDatabase
36+
DB *nais_io_v1.CloudSqlDatabase
3837
Instance *googlesqlcrd.SQLInstance
3938
}
4039

@@ -103,17 +102,6 @@ func (in GoogleSqlUser) createSqlUserDBResources(objectMeta metav1.ObjectMeta, a
103102
ast.AppendOperation(resource.OperationCreateIfNotExists, googleSqlUser)
104103
}
105104

106-
func (in GoogleSqlUser) filterDefaultUserKey(key string, suffix string) string {
107-
if in.prefixIsSet() && in.isDefault() {
108-
prefix := in.googleSqlUserPrefix()
109-
noPrefixSubstring := strings.TrimPrefix(key, prefix)
110-
if noPrefixSubstring == suffix {
111-
return key
112-
}
113-
}
114-
return ""
115-
}
116-
117105
func (in GoogleSqlUser) sqlUserEnvPrefix() string {
118106
if in.prefixIsSet() {
119107
return strings.TrimSuffix(in.DB.EnvVarPrefix, "_")

pkg/resourcecreator/ingress/ingress.go

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type Source interface {
3030

3131
type Config interface {
3232
GetGatewayMappings() []config.GatewayMapping
33-
IsLinkerdEnabled() bool
3433
GetDocUrl() string
3534
GetClusterName() string
3635
}

pkg/resourcecreator/ingress/ingress_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func TestIngress(t *testing.T) {
2323
assert.NoError(t, err)
2424

2525
opts := &generators.Options{}
26-
opts.Config.Features.Linkerd = false
2726
err = ingress.Create(app, ast, opts)
2827

2928
assert.NotNil(t, err)
@@ -40,7 +39,6 @@ func TestIngress(t *testing.T) {
4039
assert.NoError(t, err)
4140

4241
opts := &generators.Options{}
43-
opts.Linkerd = true
4442
opts.Config.GatewayMappings = []config.GatewayMapping{
4543
{
4644
DomainSuffix: ".bar",

pkg/resourcecreator/networkpolicy/networkpolicy.go

-34
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type Config interface {
2929
GetGoogleProjectID() string
3030
GetNaisNamespace() string
3131
IsNetworkPolicyEnabled() bool
32-
IsLegacyGCP() bool
3332
}
3433

3534
func baseNetworkPolicy(source Source) *networkingv1.NetworkPolicy {
@@ -47,13 +46,6 @@ func Create(source Source, ast *resource.Ast, cfg Config) {
4746
return
4847
}
4948

50-
if cfg.IsLegacyGCP() {
51-
np := baseNetworkPolicy(source)
52-
np.Spec = legacyNetpolSpec(source.GetName(), cfg.GetClusterName())
53-
np.SetName(source.GetName() + "-legacy")
54-
ast.AppendOperation(resource.OperationCreateOrUpdate, np)
55-
}
56-
5749
np := baseNetworkPolicy(source)
5850
np.Spec = netpolSpec(source.GetName(), cfg, source.GetAccessPolicy(), source.GetIngress(), source.GetLeaderElection())
5951
ast.AppendOperation(resource.OperationCreateOrUpdate, np)
@@ -225,32 +217,6 @@ func defaultIngressRules(cfg Config) []networkingv1.NetworkPolicyIngressRule {
225217
}
226218
}
227219

228-
func legacyNetpolSpec(appName string, clusterName string) networkingv1.NetworkPolicySpec {
229-
return networkingv1.NetworkPolicySpec{
230-
PodSelector: *labelSelector("app", appName),
231-
PolicyTypes: []networkingv1.PolicyType{
232-
networkingv1.PolicyTypeIngress,
233-
networkingv1.PolicyTypeEgress,
234-
},
235-
Ingress: []networkingv1.NetworkPolicyIngressRule{
236-
{
237-
From: []networkingv1.NetworkPolicyPeer{
238-
{
239-
NamespaceSelector: labelSelector("linkerd.io/is-control-plane", "true"),
240-
},
241-
},
242-
},
243-
},
244-
Egress: []networkingv1.NetworkPolicyEgressRule{
245-
{
246-
To: []networkingv1.NetworkPolicyPeer{{
247-
NamespaceSelector: labelSelector("linkerd.io/is-control-plane", "true"),
248-
}},
249-
},
250-
},
251-
}
252-
}
253-
254220
func ingressRulesFromAccessPolicy(policy *nais_io_v1.AccessPolicy, options Config) []networkingv1.NetworkPolicyIngressRule {
255221
if policy == nil || policy.Inbound == nil || len(policy.Inbound.Rules) == 0 {
256222
return nil

0 commit comments

Comments
 (0)