-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved portal related k8s operations to k8s/portal.go file. Implemente…
…d first phase of the CR Signed-off-by: Burak Sekili <buraksekili@gmail.com>
- Loading branch information
1 parent
92d2528
commit 73e0851
Showing
9 changed files
with
128 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package k8s | ||
|
||
import ( | ||
"context" | ||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// BootstrapTykPortalSecret creates a secret required by Tyk Developer Portal pod which | ||
// is not going to be ready until this secret is created. If there is a secret created already, | ||
// it deletes the existing one and recreates the secret. | ||
func (c *Client) BootstrapTykPortalSecret() error { | ||
err := c.clientSet. | ||
CoreV1(). | ||
Secrets(c.appArgs.K8s.ReleaseNamespace). | ||
Delete(context.TODO(), c.appArgs.DevPortalKubernetesSecretName, metav1.DeleteOptions{}) | ||
if err != nil { | ||
if !errors.IsNotFound(err) { | ||
return err | ||
} | ||
} | ||
|
||
secretData := map[string][]byte{ | ||
tykAuthKey: []byte(c.appArgs.Tyk.Admin.Auth), | ||
tykOrgKey: []byte(c.appArgs.Tyk.Org.ID), | ||
} | ||
|
||
objectMeta := metav1.ObjectMeta{Name: c.appArgs.DevPortalKubernetesSecretName} | ||
|
||
secret := v1.Secret{ | ||
ObjectMeta: objectMeta, | ||
Data: secretData, | ||
} | ||
|
||
_, err = c.clientSet. | ||
CoreV1(). | ||
Secrets(c.appArgs.K8s.ReleaseNamespace). | ||
Create(context.TODO(), &secret, metav1.CreateOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.