Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
import * as k8s from "@pulumi/kubernetes";
// Create resources from standard Kubernetes guestbook YAML example.
const guestbook = new k8s.yaml.ConfigGroup("guestbook", { files: "yaml/*.yaml" });
// Export the (cluster-private) IP address of the Guestbook frontend.
export const frontendIp = guestbook.getResource("v1/Service", "frontend", "spec").clusterIP;
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import * as k8s from "@pulumi/kubernetes";
//
// Force a rollout and ensure update completes successfully.
//
new k8s.yaml.ConfigFile("alias-test", {file: "manifests/av1DeploymentRollout.yaml"});
export function createDashboard(name: string, args: DashboardOptions, parent: pulumi.ComponentResource, k8sProvider: k8s.Provider) {
// Deploy the latest version of the k8s dashboard.
const dashboardYaml = [
path.join(__dirname, "dashboard", "kubernetes-dashboard.yaml"),
path.join(__dirname, "dashboard", "heapster.yaml"),
path.join(__dirname, "dashboard", "influxdb.yaml"),
path.join(__dirname, "dashboard", "heapster-rbac.yaml"),
].map(filePath => fs.readFileSync(filePath).toString());
const dashboard = new k8s.yaml.ConfigGroup(`${name}-dashboard`, {
yaml: dashboardYaml,
}, { parent: parent, providers: { kubernetes: k8sProvider } });
// Create a service account for admin access.
const adminAccount = new k8s.core.v1.ServiceAccount(`${name}-eks-admin`, {
metadata: {
name: "eks-admin",
namespace: "kube-system",
},
}, { parent: parent, provider: k8sProvider });
// Create a role binding for the admin account.
const adminRoleBinding = new k8s.rbac.v1.ClusterRoleBinding(`${name}-eks-admin`, {
metadata: {
name: "eks-admin",
},
constructor(
name: string,
args: PrometheusOperatorArgs,
opts?: pulumi.ComponentResourceOptions,
) {
super('pulumi:monitoring/v1:PrometheusOperator', name, {}, opts);
this.configFile = new k8s.yaml.ConfigFile(name, {
file: 'https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.38.1/bundle.yaml',
}, {parent: this});
this.service = this.configFile.getResource("v1/Service", "default", "prometheus-operator");
}
}
function configFile(name: string, namespace: string, resourcePrefix?: string): k8s.yaml.ConfigFile {
return new k8s.yaml.ConfigFile(name, {
file: "https://raw.githubusercontent.com/pulumi/pulumi-kubernetes/master/tests/examples" +
"/yaml-guestbook/yaml/guestbook.yaml",
resourcePrefix: resourcePrefix,
transformations: [
(obj: any) => {
if (obj !== undefined) {
if (obj.metadata !== undefined) {
obj.metadata.namespace = namespace;
} else {
obj.metadata = {namespace: namespace};
}
}
}
]
});
}
password: Buffer.from(rawPW).toString("base64"),
}
});
const randSuffix = Math.random().toString(36).substring(7);
const name = `test-${randSuffix}`;
const secretYaml = `
apiVersion: v1
kind: Secret
metadata:
name: ${name}
stringData:
password: ${rawPW}
`
const cg = new k8s.yaml.ConfigGroup("example", {
yaml: secretYaml,
});
export const cmDataData = cmData.data;
export const cmBinaryDataData = cmBinaryData.binaryData;
export const ssStringDataData = ssStringData.data;
export const ssDataData = ssData.data;
export const cgSecret = cg.getResource("v1/Secret", name).stringData;
constructor(
name: string,
args: PrometheusOperatorArgs,
opts?: pulumi.ComponentResourceOptions,
) {
super('pulumi:monitoring/v1:PrometheusOperator', name, {}, opts);
this.configFile = new k8s.yaml.ConfigFile(name, {
file: 'https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.38.1/bundle.yaml',
}, {parent: this});
this.service = this.configFile.getResource("v1/Service", "default", "prometheus-operator");
}
}
{ provider: k8sProvider }
);
function addNamespace(o: any) {
if (o !== undefined) {
o.metadata.namespace = "bookinfo";
}
}
const bookinfo = new k8s.yaml.ConfigFile(
"yaml/bookinfo.yaml",
{ transformations: [addNamespace] },
{ dependsOn: istio, providers: { kubernetes: k8sProvider } }
);
new k8s.yaml.ConfigFile(
"yaml/bookinfo-gateway.yaml",
{ transformations: [addNamespace] },
{ dependsOn: bookinfo, providers: { kubernetes: k8sProvider } }
);
export const port = istio
.getResourceProperty("v1/Service","istio-system", "istio-ingressgateway", "spec")
.apply(p => p.ports.filter(p => p.name == "http2"));
export const frontendIp = pulumi
.all([
istio.getResourceProperty("v1/Service", "istio-system", "istio-ingressgateway", "status"),
istio.getResourceProperty("v1/Service", "istio-system", "istio-ingressgateway", "spec")
])
.apply(([status, spec]) => {
const port = spec.ports.filter(p => p.name == "http2")[0].port;
function configFile(name: string, namespace: string, resourcePrefix?: string): k8s.yaml.ConfigFile {
return new k8s.yaml.ConfigFile(name, {
file: "https://raw.githubusercontent.com/pulumi/pulumi-kubernetes/master/tests/sdk/nodejs/examples/yaml-guestbook/yaml/guestbook.yaml",
resourcePrefix: resourcePrefix,
transformations: [
(obj: any) => {
if (obj !== undefined) {
if (obj.metadata !== undefined) {
obj.metadata.namespace = namespace;
} else {
obj.metadata = {namespace: namespace};
}
}
}
]
});
}