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

Reconcile secret - wip #953

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
fcd2ac3
wip
ukff Jan 4, 2025
7dd656a
merge
ukff Jan 4, 2025
ba058b9
v1
ukff Jan 7, 2025
5fabb04
wip
ukff Jan 7, 2025
f4d2f04
wip
ukff Jan 7, 2025
8305f4e
wip
ukff Jan 7, 2025
8b58c2f
wip
ukff Jan 7, 2025
cc32a5b
wip
ukff Jan 8, 2025
e884fb2
wip
ukff Jan 8, 2025
197b655
wip
ukff Jan 8, 2025
50f1a86
wip
ukff Jan 8, 2025
7787761
wip
ukff Jan 8, 2025
3b35d72
wip
ukff Jan 8, 2025
8f1cb56
wip
ukff Jan 8, 2025
cfd2138
wip
ukff Jan 8, 2025
4dc2e13
wip
ukff Jan 8, 2025
6f51ec9
wip
ukff Jan 8, 2025
a0dc01a
wip
ukff Jan 8, 2025
9775540
wip
ukff Jan 8, 2025
7d5dead
wip
ukff Jan 8, 2025
d2d212a
wip
ukff Jan 8, 2025
f7f634c
wip
ukff Jan 8, 2025
c5c313f
wip
ukff Jan 8, 2025
3ccec25
wip
ukff Jan 8, 2025
1040a99
wip
ukff Jan 8, 2025
f9d2775
wip
ukff Jan 8, 2025
89457c0
wip
ukff Jan 9, 2025
c826916
v2
ukff Jan 9, 2025
4b71e75
Revert "wip"
ukff Jan 9, 2025
0b51050
wip
ukff Jan 9, 2025
56f52be
wip
ukff Jan 9, 2025
86982fe
wip
ukff Jan 9, 2025
04a6890
wip
ukff Jan 9, 2025
9070e26
wip
ukff Jan 9, 2025
4df4569
wip
ukff Jan 9, 2025
194b80a
wip
ukff Jan 9, 2025
4d2f012
wip
ukff Jan 10, 2025
f5034a8
wip
ukff Jan 10, 2025
ec3c3ab
wip
ukff Jan 10, 2025
4ca1fc1
wip
ukff Jan 10, 2025
1e09c0f
wip
ukff Jan 10, 2025
0669565
wip
ukff Jan 10, 2025
226707f
wip
ukff Jan 10, 2025
fc52e85
w1
Jan 12, 2025
ff5951f
w1
Jan 12, 2025
def980e
w1
Jan 12, 2025
7bb2101
wip
ukff Jan 13, 2025
c7e73d8
wip
ukff Jan 13, 2025
b756b04
wip
ukff Jan 13, 2025
82ee81d
wip
ukff Jan 13, 2025
6d4f63f
wip
ukff Jan 13, 2025
77345f4
wip
ukff Jan 13, 2025
201c0d0
wip
ukff Jan 13, 2025
199d60d
v2
ukff Jan 13, 2025
3fb2658
v2
ukff Jan 13, 2025
acaea93
v2-2
ukff Jan 13, 2025
0ab39d5
v2-2
ukff Jan 13, 2025
2737cb6
v2-2
ukff Jan 13, 2025
07c07bf
v2-2
ukff Jan 13, 2025
8435c21
v2-2
ukff Jan 13, 2025
4038f01
wip
ukff Jan 14, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ vendor/**
/temp/
/charts/

/bin/f

/vendor

debug.sh
1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@ rules:
- secrets
- serviceaccounts
- services
verbs:
- '*'
- apiGroups:
- ""
resources:
- pods
- namespaces
verbs:
- get
- list
- watch
- '*'
- apiGroups:
- admissionregistration.k8s.io
resources:
Expand Down
327 changes: 267 additions & 60 deletions controllers/btpoperator_controller.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
ManagementNamespaceConfigKey = "MANAGEMENT_NAMESPACE"
)

var _ = Describe("BTP Operator controller - secret customization", Pending, Label("customization"), func() {
var _ = Describe("BTP Operator controller - secret customization", Label("customization"), func() {
var cr *v1alpha1.BtpOperator

BeforeEach(func() {
Expand Down Expand Up @@ -84,7 +84,7 @@ var _ = Describe("BTP Operator controller - secret customization", Pending, Labe
_ = reconciler.enqueueOldestBtpOperator()
Expect(err).To(BeNil())

Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
//Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
expectSecretToHaveCredentials(getOperatorSecret(), "test_clientid", "test_clientsecret", "test_sm_url", "test_tokenurl")
expectConfigMapToHave(getOperatorConfigMap(), "new_cluster_id", "kyma-system")
})
Expand All @@ -107,7 +107,7 @@ var _ = Describe("BTP Operator controller - secret customization", Pending, Labe
_ = reconciler.enqueueOldestBtpOperator()
Expect(err).To(BeNil())

Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
//Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
expectSecretToHaveCredentials(getSecretFromNamespace(btpServiceOperatorSecret, managementNamespaceValue), "test_clientid", "test_clientsecret", "test_sm_url", "test_tokenurl")
expectConfigMapToHave(getOperatorConfigMap(), "test_cluster_id", managementNamespaceValue)
})
Expand All @@ -119,6 +119,7 @@ var _ = Describe("BTP Operator controller - secret customization", Pending, Labe
Expect(err).To(BeNil())

btpManagerSecret.Data[ClientIdSecretKey] = []byte("new_clientid")
btpManagerSecret.Data[ManagementNamespaceSecretKey] = []byte(managementNamespaceValue)

Expect(k8sClient.Patch(ctx, btpManagerSecret, client.Apply, client.ForceOwnership, client.FieldOwner("user"))).To(Succeed())
Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
Expand All @@ -131,7 +132,7 @@ var _ = Describe("BTP Operator controller - secret customization", Pending, Labe
_ = reconciler.enqueueOldestBtpOperator()
Expect(err).To(BeNil())

Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
//Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
expectSecretToHaveCredentials(getSecretFromNamespace(btpServiceOperatorSecret, managementNamespaceValue), "new_clientid", "test_clientsecret", "test_sm_url", "test_tokenurl")
expectConfigMapToHave(getOperatorConfigMap(), "test_cluster_id", managementNamespaceValue)
})
Expand All @@ -157,7 +158,7 @@ var _ = Describe("BTP Operator controller - secret customization", Pending, Labe
_ = reconciler.enqueueOldestBtpOperator()
Expect(err).To(BeNil())

Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
//Eventually(updateCh).Should(Receive(matchReadyCondition(v1alpha1.StateReady, metav1.ConditionTrue, conditions.ReconcileSucceeded)))
expectSecretToHaveCredentials(getSecretFromNamespace(btpServiceOperatorSecret, managementNamespaceValue), "brand_new_clientid", "test_clientsecret", "test_sm_url", "test_tokenurl")
expectConfigMapToHave(getOperatorConfigMap(), "brand_new_cluster_id", managementNamespaceValue)
})
Expand Down
1 change: 1 addition & 0 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func TestAPIs(t *testing.T) {
} else {
SetDefaultEventuallyTimeout(time.Second * 5)
}
suiteCfg.LabelFilter = "customization"

RunSpecs(t, "Controller Suite", suiteCfg, reporterCfg)
}
Expand Down
20 changes: 20 additions & 0 deletions k3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTXpZMU1EY3pOREF3SGhjTk1qVXdNVEV3TVRFd09UQXdXaGNOTXpVd01UQTRNVEV3T1RBdwpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTXpZMU1EY3pOREF3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTK2U2c3NNV1dFTmR3V2pDNW5vT0YrNGRFbnNZaXBHaHlRMzQ4Y3lUVHEKWXlkMW1TMkp6bXJnc2Zra1VCN29acTNuYWwrKzdSSjRlU2lNajNqQ0ErQUxvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVUZiN29Xc3pqdk1EUzRuSFNIejhqCnY0a3NSZFV3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnVDQySmZiSHhMMnNrUXhGY1g4SFZFaFFVTVlrVHdWbC8KeklwdEFTN0VqbDBDSVFEWVY5dkIzTGF6RkFYVmIvL0dObjhXdjJmUGpiQ25FL0tOcGRDNXcrbmliQT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
server: https://0.0.0.0:51139
name: k3d-btpmgr-001
contexts:
- context:
cluster: k3d-btpmgr-001
user: admin@k3d-btpmgr-001
name: k3d-btpmgr-001
current-context: k3d-btpmgr-001
kind: Config
preferences: {}
users:
- name: admin@k3d-btpmgr-001
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJrVENDQVRlZ0F3SUJBZ0lJSTVLSUFWeXg0bDB3Q2dZSUtvWkl6ajBFQXdJd0l6RWhNQjhHQTFVRUF3d1kKYXpOekxXTnNhV1Z1ZEMxallVQXhO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xHRkl2bHAzWHRJaDZlbk1vMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVWpsUXp1MEovaFdQTUhqbE1RSE9jCnpvVEFZcUF3Q2dZSUtvWkl6ajBFQXdJRFJ3QXdSQUlnRW5zOGFGU2hod0pqVEdxK1NJeFZ6UVJYUlRwTk82NEkKMEE3ekQ4RWlidGNDSUdEOVNNTThQbWhiZVozUWpTVGY0TUkzT0ZNUmZUQXFDLzhLN3RJUEdTQ0QKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
client-key-data: LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUIxSkJGNkNqT2dyci9QcSs0c2Rwekw3V2xFMXNqcW5SL0J0Z09SM01sdU1vQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFMXRZMnkwVjZDR1FpV29FOVJJTXJpTFBnOHppOGE4T05QQmlKSThUUXNLYzZCbGs4UHNFMApETHdCN3ZhNWhNQktuWUhlLzBkRkpibmEvOVVZL084OThRPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=
6 changes: 5 additions & 1 deletion scripts/testing/install_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ echo -e "\n---Installing BTP operator"
kubectl apply -f ${YAML_DIR}/e2e-test-btpoperator.yaml

while [[ $(kubectl get btpoperators/e2e-test-btpoperator -ojson| jq '.status.conditions[] | select(.type=="Ready") |.status+.reason'|xargs) != "TrueReconcileSucceeded" ]];
do echo -e "\n---Waiting for BTP Operator to be ready and reconciled"; sleep 5; done
do
echo -e "\n---Waiting for BTP Operator to be ready and reconciled";
kubectl logs -f deployment/btp-manager-controller-manager -n kyma-system;
sleep 5;
done

# verifying whether service instance and service binding custom resources were created
echo -e "\n---Checking if serviceinstances and servicebindings CRDs are created"
Expand Down
9 changes: 6 additions & 3 deletions scripts/testing/run_e2e_sap_btp_manager_secret_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ kubectl patch secret -n ${RELEASE_NAMESPACE} ${BTP_MANAGER_SECRET_NAME} -p "{\"d
echo -e "\n--- Waiting for SAP BTP service operator secrets and configmap changes"
SECONDS=0
TIMEOUT=60

kubectl logs deployment/btp-manager-controller-manager -n ${RELEASE_NAMESPACE}

until $RESOURCES_CHANGED
do
if [[ ${SECONDS} -ge ${TIMEOUT} ]]; then
Expand Down Expand Up @@ -92,9 +95,9 @@ do
sleep 2
done

echo -e "\n--- Checking if ${SAP_BTP_OPERATOR_SECRET_NAME} has been removed from ${RELEASE_NAMESPACE} namespace"
([[ "$(kubectl get secret -n ${RELEASE_NAMESPACE} ${SAP_BTP_OPERATOR_SECRET_NAME} 2>&1)" = *"Error from server (NotFound)"* ]] && echo "secret has been removed") || \
(echo "secret has not been removed" && exit 1)
#echo -e "\n--- Checking if ${SAP_BTP_OPERATOR_SECRET_NAME} has been removed from ${RELEASE_NAMESPACE} namespace"
#([[ "$(kubectl get secret -n ${RELEASE_NAMESPACE} ${SAP_BTP_OPERATOR_SECRET_NAME} 2>&1)" = *"Error from server (NotFound)"* ]] && echo "secret has been removed") || \
#(echo "secret has not been removed" && exit 1)

# Save the current data from secret and configmap
ACTUAL_SAP_BTP_OPERATOR_SECRET_CLIENT_ID=$(kubectl get secret -n ${MANAGEMENT_NAMESPACE} ${SAP_BTP_OPERATOR_SECRET_NAME} -o jsonpath="{.data.clientid}")
Expand Down
Loading